search
HomeWeb Front-endVue.js13 front-end Vue interview questions to share (with answer analysis)

This article will share with you some front-end vue interview questions. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

13 front-end Vue interview questions to share (with answer analysis)

vue interview questions

1.How vue-router passes parameters
2.v- Disadvantages and solutions of using if and v-for together
3.What operations are generally performed in beforeDestroyed
4.How to transfer values ​​​​between components of the same level in vue
5.How do parent components in vue obtain child components? Properties and methods
6.The difference between watch and computed
7.The order of the life cycle of parent component and child component in vue
8.Can the parent component in vue monitor the life cycle of the child component
9. What are the main event modifiers in Vue? What are their respective functions
10. Introduce what is
11.Can watch monitor the pop behavior of the array?
12.How does watch implement deep monitoring
13. How to solve the problem of page not re-rendering in vue
(Learning video sharing: vue video tutorial)

vue interview question analysis

1. vue-router has two ways to pass parameters

(1) Dynamically pass parameters eg by configuring the path in the router.js file: path: ' /detail/:id' and then pass this.$route.params.id in the component to get

(2). Pass the parameter

<router-link :to={
params: {
	x: 1
	}
} />

in the router-link tag and also pass this .$route.params gets

Note: The way to pass parameters through router-link here is to pass parameters implicitly

2, v-if and v Disadvantages and solutions of using -for together

Since v-for has a higher priority than v-if, v-if will be visited every time the loop is passed, and v-if is passed Create and destroy DOM elements to control the display and hiding of elements, so elements will be constantly created and destroyed, causing page lag and performance degradation.

Solution: Use v-if by wrapping an element in the outer or inner layer of v-for

3. What operations are generally performed in beforeDestroy

beforedestoryed is a life cycle executed before the component is destroyed. In this life cycle, we can clear callback functions or timers, clear unused dom elements, etc.

4, vue How to transfer values ​​between components at the same level

1. If it is a sibling component, the value can be transferred through the parent element as an intermediate component 2. By creating a bus, the value can be transferred

// 创建一个文件,定义bus中间件,并导出
const bus = new Vue()
// 在一个组件中发送事件
bus.$emit(&#39;事件名称&#39;, 传递的参数)
// 在另一个组件中监听事件
bus.$on(&#39;事件名称&#39;, 得到传过来的参数)

5. How does the parent component in vue obtain the properties and methods of the subcomponent

Vue obtains the properties and methods of the subcomponent by defining the ref attribute on the subcomponent. The code is as follows:

// 这里是父组件
<templete>
	<child ref="child"/>
</templete>
<script>
method: {
	getChild () {
		this.$refs.child.属性名(方法名)
	}
}
</script>

6. The difference between watch and computed

The function of watch is usually that one value affects the changes of multiple values ​​and when it can monitor the change of this value, it will execute a Callback function, at this time we can do some logical processing in this callback function

computed is to derive a new value based on the dependent value, and there can be multiple dependent values, only when the dependent value When changes occur, the calculation will be re-executed

[Related recommendations: vue.js tutorial]

7. The life cycle of vue parent components and child components Sequence

1), rendering process sequence:

parent component beforeCreate() -> parent component created() -> parent component beforeMount() -> child component beforeCreate () ->Subcomponent created() -> Subcomponent beforeMount() -> Subcomponent mounted() -> Parent component mounted()

2), update process sequence:

Update process of parent component:
Parent component beforeUpdate() -> Parent component updated()

Update process of child component:
Parent component beforeUpdate() -> Child component beforeUpdate( ) -> Child component updated() -> Parent component updated()

3), destruction process
Parent component beforeDestroy() -> Child component beforeDestroy() -> Child component destroyed () -> Parent component destroyed()

8. Can the parent component in Vue monitor the life cycle of the child component?

Can the parent component monitor the child component? The life cycle of the monitoring code through @hook: is as follows:

// 这里是父组件
<template>
	<child
	@hook:mounted="getChildMounted"
	/>
</template>
<script>
method: {
	getChildMounted () {
		// 这里可以获取到子组件mounted的信息
	}
}
</script>

9. What are the main event modifiers in vue? What are the functions?

.stop: prevent events from bubbling
.native: bind native events
.once: events are executed only once
.self: bind events On itself, it is equivalent to preventing events from bubbling
.prevent: Preventing default events
.caption: Used for event capture

10. Introduce what is keep-alive

keep-alive is used for component caching. It will only be executed once and will not be destroyed. Components wrapped by keep-alive do not have methods such as create and beforeDestroyed, but they have activated and deactivated methods.

11. Can the watch monitor the pop behavior of the array?

对于有返回值的数据,watch就能监听到,比如数组的pop,push, unshift,map等行为。

12、watch如何实现深度监听

watch: {
	obj: {
		handler: function(val) {
		},
		deep: true // 深度监听
	}
}

13、vue中如何解决页面不重新渲染问题

(1).修改对象属性后页面未重新渲染可以使用 this.$set(对象名称, '属性名', '属性值') (2).使用this.$forceUpdate()方法可重新渲染页面

更多编程相关知识,请访问:编程视频!!

The above is the detailed content of 13 front-end Vue interview questions to share (with answer analysis). For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:csdn. If there is any infringement, please contact admin@php.cn delete
Vue.js's Function: Enhancing User Experience on the FrontendVue.js's Function: Enhancing User Experience on the FrontendApr 19, 2025 am 12:13 AM

Vue.js improves user experience through multiple functions: 1. Responsive system realizes real-time data feedback; 2. Component development improves code reusability; 3. VueRouter provides smooth navigation; 4. Dynamic data binding and transition animation enhance interaction effect; 5. Error processing mechanism ensures user feedback; 6. Performance optimization and best practices improve application performance.

Vue.js: Defining Its Role in Web DevelopmentVue.js: Defining Its Role in Web DevelopmentApr 18, 2025 am 12:07 AM

Vue.js' role in web development is to act as a progressive JavaScript framework that simplifies the development process and improves efficiency. 1) It enables developers to focus on business logic through responsive data binding and component development. 2) The working principle of Vue.js relies on responsive systems and virtual DOM to optimize performance. 3) In actual projects, it is common practice to use Vuex to manage global state and optimize data responsiveness.

Understanding Vue.js: Primarily a Frontend FrameworkUnderstanding Vue.js: Primarily a Frontend FrameworkApr 17, 2025 am 12:20 AM

Vue.js is a progressive JavaScript framework released by You Yuxi in 2014 to build a user interface. Its core advantages include: 1. Responsive data binding, automatic update view of data changes; 2. Component development, the UI can be split into independent and reusable components.

Netflix's Frontend: Examples and Applications of React (or Vue)Netflix's Frontend: Examples and Applications of React (or Vue)Apr 16, 2025 am 12:08 AM

Netflix uses React as its front-end framework. 1) React's componentized development model and strong ecosystem are the main reasons why Netflix chose it. 2) Through componentization, Netflix splits complex interfaces into manageable chunks such as video players, recommendation lists and user comments. 3) React's virtual DOM and component life cycle optimizes rendering efficiency and user interaction management.

The Frontend Landscape: How Netflix Approached its ChoicesThe Frontend Landscape: How Netflix Approached its ChoicesApr 15, 2025 am 12:13 AM

Netflix's choice in front-end technology mainly focuses on three aspects: performance optimization, scalability and user experience. 1. Performance optimization: Netflix chose React as the main framework and developed tools such as SpeedCurve and Boomerang to monitor and optimize the user experience. 2. Scalability: They adopt a micro front-end architecture, splitting applications into independent modules, improving development efficiency and system scalability. 3. User experience: Netflix uses the Material-UI component library to continuously optimize the interface through A/B testing and user feedback to ensure consistency and aesthetics.

React vs. Vue: Which Framework Does Netflix Use?React vs. Vue: Which Framework Does Netflix Use?Apr 14, 2025 am 12:19 AM

Netflixusesacustomframeworkcalled"Gibbon"builtonReact,notReactorVuedirectly.1)TeamExperience:Choosebasedonfamiliarity.2)ProjectComplexity:Vueforsimplerprojects,Reactforcomplexones.3)CustomizationNeeds:Reactoffersmoreflexibility.4)Ecosystema

The Choice of Frameworks: What Drives Netflix's Decisions?The Choice of Frameworks: What Drives Netflix's Decisions?Apr 13, 2025 am 12:05 AM

Netflix mainly considers performance, scalability, development efficiency, ecosystem, technical debt and maintenance costs in framework selection. 1. Performance and scalability: Java and SpringBoot are selected to efficiently process massive data and high concurrent requests. 2. Development efficiency and ecosystem: Use React to improve front-end development efficiency and utilize its rich ecosystem. 3. Technical debt and maintenance costs: Choose Node.js to build microservices to reduce maintenance costs and technical debt.

React, Vue, and the Future of Netflix's FrontendReact, Vue, and the Future of Netflix's FrontendApr 12, 2025 am 12:12 AM

Netflix mainly uses React as the front-end framework, supplemented by Vue for specific functions. 1) React's componentization and virtual DOM improve the performance and development efficiency of Netflix applications. 2) Vue is used in Netflix's internal tools and small projects, and its flexibility and ease of use are key.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft