# Component Vue (Vue.js / Nuxt.js) > Vòng đời component, props, events, slots, scoped styles, giao tiếp giữa các component, component động - 20 câu hỏi phỏng vấn - Junior - [Câu hỏi phỏng vấn: Vue.js / Nuxt.js](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van.md) ## 1. Component Vue là gì? **Câu trả lời** Component Vue là một Vue instance có thể tái sử dụng và có tên. Nó đóng gói HTML, CSS và JavaScript thành một đơn vị logic độc lập. Các component cho phép chia giao diện người dùng thành những phần có thể tái sử dụng và dễ bảo trì. Mỗi component có template, logic và style riêng, giúp việc tổ chức mã nguồn và tái sử dụng trở nên dễ dàng hơn. ## 2. Làm thế nào để khai báo props trong một component Vue 3 với script setup? **Câu trả lời** Trong Vue 3 với script setup, defineProps() là một compiler macro cho phép khai báo props mà không cần import tường minh. Macro này tự động tạo ra mã cần thiết và đưa props vào template. Nó hỗ trợ kiểm tra kiểu của TypeScript và JavaScript, giúp mã ngắn gọn và an toàn về kiểu hơn so với cách tiếp cận Options API. ## 3. Hook onMounted() có chức năng gì trong lifecycle của một component? **Câu trả lời** Hook onMounted() được thực thi sau khi component đã được mount vào DOM. Đây là thời điểm lý tưởng để thực hiện các thao tác cần truy cập DOM, như khởi tạo thư viện bên thứ ba, lấy dữ liệu qua API, hoặc thao tác trực tiếp với các phần tử DOM. Ở giai đoạn này, template đã được render và có thể truy cập các refs. ## Còn 17 câu hỏi nữa - Làm thế nào để một component con emit một event đến component cha của nó? - Slots được dùng để làm gì trong một component Vue? Đăng ký miễn phí: https://sharpskill.dev/vi/login ## Các chủ đề phỏng vấn Vue.js / Nuxt.js khác - [Kiến thức nền tảng JavaScript](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/javascript-fundamentals.md): 20 câu hỏi, Junior - [JavaScript hiện đại (ES6+)](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/es6-modern-javascript.md): 20 câu hỏi, Junior - [Kiến thức cơ bản về Vue](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/vue-basics.md): 22 câu hỏi, Junior - [Vue Router](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/vue-router.md): 18 câu hỏi, Junior - [Pinia State Management](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/pinia-state-management.md): 20 câu hỏi, Junior - [Vuex (Legacy)](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/vuex-legacy.md): 15 câu hỏi, Mid-Level - [Composition API](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/composition-api.md): 24 câu hỏi, Mid-Level - [Tính reactive của Vue](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/vue-reactivity.md): 20 câu hỏi, Mid-Level - [Kiến thức cơ bản về Nuxt](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/nuxt-fundamentals.md): 22 câu hỏi, Mid-Level - [Data Fetching trong Nuxt](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/nuxt-data-fetching.md): 20 câu hỏi, Mid-Level - [SSR & SSG trong Nuxt](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/nuxt-ssr-ssg.md): 22 câu hỏi, Mid-Level - [Server Routes Nuxt](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/nuxt-server-routes.md): 20 câu hỏi, Mid-Level - [Module Nuxt](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/nuxt-modules.md): 18 câu hỏi, Mid-Level - [Composables trong Vue](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/vue-composables.md): 20 câu hỏi, Mid-Level - [Form & Validation Vue](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/vue-forms-validation.md): 20 câu hỏi, Mid-Level - [Quản lý trạng thái Nuxt](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/nuxt-state-management.md): 18 câu hỏi, Mid-Level - [Testing trong Vue](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/vue-testing.md): 20 câu hỏi, Mid-Level - [Triển khai Nuxt & CI/CD](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/nuxt-deployment-cicd.md): 22 câu hỏi, Mid-Level - [Hiệu năng Vue](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/vue-performance.md): 22 câu hỏi, Senior - [Các mẫu nâng cao trong Vue](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/vue-advanced-patterns.md): 24 câu hỏi, Senior - [TypeScript với Vue](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/typescript-vue.md): 22 câu hỏi, Senior - [Xác thực Nuxt](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/nuxt-auth.md): 20 câu hỏi, Senior - [SEO với Nuxt](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/nuxt-seo.md): 20 câu hỏi, Senior - [Quốc tế hóa trong Nuxt](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/nuxt-i18n.md): 18 câu hỏi, Senior - [Kiến trúc Vue](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/vue-architecture.md): 22 câu hỏi, Senior - [Bảo mật Nuxt](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/nuxt-security.md): 20 câu hỏi, Senior - [Hệ sinh thái Vue](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/vue-ecosystem.md): 18 câu hỏi, Senior - [Di chuyển Vue 2→3 & Nuxt 2→3](https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/migration-vue2-vue3-nuxt2-nuxt3.md): 22 câu hỏi, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/vi/technologies/vue-nuxt/cau-hoi-phong-van/vue-components