This article brings you an introduction to Vue interview questions (with answers). It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
Vue is becoming more and more popular. Looking at domestic and foreign countries, Vue has a wide range of applications, whether it is large companies such as BAT or start-up companies. During the interview, Vue-related technical principles must also be tested. It can be said that for any front-end engineer, mastering Vue may not be an option, but more like a "required course".
Many people working on Vue projects directly use element ui and other UI frameworks. Although these frameworks help us a lot in terms of efficiency, they actually do not improve our technology at all. You will definitely not be able to answer the Vue core technology asked by the interviewer.
For a developer, if you only know how to use a technical framework and never understand the implementation principles and design ideas behind the core technology in this framework, I You will definitely not go far on the road of technology. As a developer, I have a very deep experience. Here I would like to give you a heart-warming recommendation. The author of the UI framework ant Design vue launched a UI framework in Geek Time. The course is called Vue Development Practical (there is a purchase link at the bottom of the article). I also purchased this course myself, and I think the lectures are good. It will help you master the technical principles and applications of Vue, and you will also have an understanding of its underlying principles. Through practical projects, you will be able to independently take charge of Vue front-end projects. The ability will be very helpful for your job hopping, interviews and getting started with Vue. Many buyers, including myself, also feel that it is full of useful information. Recommended to everyone in need.
Okay, let’s get to the point. Today I will bring you some advanced interview questions about Vue.
1. What is MVVM?
Answer: MVVM is the abbreviation of Model-View-ViewModel. Model represents the data model and defines the business logic of data operations. View represents the view layer and is responsible for rendering the data model to the page. ViewModel is bound through two-way binding. A design idea that allows View and Model to interact synchronously without manually manipulating the DOM.
2. How to define dynamic routing of vue-router? How to get the passed dynamic parameters?
Answer: In the index.js file in the router directory, add /:id to the path attribute. Using the params.id of the router object
3. What kind of navigation hooks does vue-router have?
Answer: Three types. One is the global navigation hook: router.beforeEach(to,from,next). Its function is to judge and intercept before jumping. The second type: hooks within components; the third type: independent routing of exclusive components
4. What is vuex? how to use? Which functional scenario uses it?
Answer: State management in the vue framework. Introduce store into main.js and inject it. A new directory store is created,...export. Scenarios include: status between components in a single-page application. Music playback, login status, adding to shopping cart
5. What is the difference between MVVM and MVC? How is it different from other frameworks (jquery)? Which scenarios apply?
Answer: MVVM and MVC are both design ideas. The main thing is that the Controller in MVC evolves into a ViewModel. MVVM mainly displays the view layer through data instead of operating nodes, which solves a large number of DOM operations in MVC. The page rendering performance is reduced, the loading speed is slow, and the user experience is affected. Mainly used in scenarios with a lot of data operations.
Scenario: Scenarios with a lot of data operations, more convenient
6. What is the principle of two-way data binding of Vue company?
Answer: vue.js uses data hijacking combined with the publisher-subscriber model. It uses Object.defineProperty() to hijack the setters and getters of each property, and publishes messages to subscribers when the data changes. Trigger the corresponding listening callback.
7. Please tell me the process of encapsulating vue components?
Answer: First of all, components can improve the development efficiency of the entire project. They can abstract the page into multiple relatively independent modules, solving the problems of our traditional project development: low efficiency, difficult maintenance, reusability and other problems.
Then, use the Vue.extend method to create a component, and then use the Vue.component method to register the component. Child components require data, which can be defined in props. After the child component modifies the data, it wants to pass the data to the parent component. You can use the launch method
8. Talk about your understanding of template compilation of Vue.js
Answer: In short, it is converted into an AST tree first, and then obtained The rendering function returns VNODE (Vue company's virtual DOM node)
Detailed steps:
First, compile the template into an AST syntax tree (abstract syntax tree is the tree of the abstract syntax structure of the source code) through the compiler representation), compilation is the return value of createCompiler, which is used to create a compiler. Responsible for merging options.
Then, the AST will be generated (the process of converting the AST syntax tree into a rendering function string) to obtain the rendering function. The return value of the rendering is VNode. VNode is the virtual DOM node of Vue, which contains (label name , child nodes, text, etc.)
9. What is the function of
Answer: When wrapping dynamic components, inactive component instances will be cached, mainly to retain component status or avoid re-rendering;
Usage: Simple page
Cache:
Do not cache:
10. The difference between vue and react
Answer: Similar points: both encourage componentization, have the concept of 'props', and have their own construction tools. Reat and Vue only have the skeleton of the framework, and other functions such as routing , state management, etc. are components separated by the framework.
Differences: React: one-way data flow, syntax - JSX, in React you need to use the setState() method to update the state. Vue: Two-way binding of data, syntax - HTML, state object is not required, data is managed in Vue object by data attribute. Suitable for small applications, but not suitable for large applications.
11. What are the similarities and differences between the v-show and v-if instructions?
The v-show instruction makes it display or hide by modifying the displayCSS attribute of the element. The
v-if instruction directly destroys and rebuilds the DOM to display and hide elements.
12. The difference between $route and $router
Answer: $route is a "routing information object", including path, params, hash, query, fullPath, matched, name, etc. Routing information parameters. And $router is a "routing instance" object that includes routing jump methods, hook functions, etc.
13. The role of key values in vue
Answer: When using Vue.js When v-for is updating a list of rendered elements, it defaults to an "in-place reuse" strategy. If the order of the data items is changed, Vue will not move the DOM elements to match the order of the data items, but will simply reuse each element there and make sure it displays each element that has been rendered at a specific index. The main function of key is to efficiently update the virtual DOM
This article has ended here. For more other exciting content, you can pay attention to the JavaScript Tutorial Video column of the PHP Chinese website!
Related recommendations:
The above is the detailed content of Introduction to vue interview questions (with answers). For more information, please follow other related articles on the PHP Chinese website!

Both Python and JavaScript's choices in development environments are important. 1) Python's development environment includes PyCharm, JupyterNotebook and Anaconda, which are suitable for data science and rapid prototyping. 2) The development environment of JavaScript includes Node.js, VSCode and Webpack, which are suitable for front-end and back-end development. Choosing the right tools according to project needs can improve development efficiency and project success rate.

Yes, the engine core of JavaScript is written in C. 1) The C language provides efficient performance and underlying control, which is suitable for the development of JavaScript engine. 2) Taking the V8 engine as an example, its core is written in C, combining the efficiency and object-oriented characteristics of C. 3) The working principle of the JavaScript engine includes parsing, compiling and execution, and the C language plays a key role in these processes.

JavaScript is at the heart of modern websites because it enhances the interactivity and dynamicity of web pages. 1) It allows to change content without refreshing the page, 2) manipulate web pages through DOMAPI, 3) support complex interactive effects such as animation and drag-and-drop, 4) optimize performance and best practices to improve user experience.

C and JavaScript achieve interoperability through WebAssembly. 1) C code is compiled into WebAssembly module and introduced into JavaScript environment to enhance computing power. 2) In game development, C handles physics engines and graphics rendering, and JavaScript is responsible for game logic and user interface.

JavaScript is widely used in websites, mobile applications, desktop applications and server-side programming. 1) In website development, JavaScript operates DOM together with HTML and CSS to achieve dynamic effects and supports frameworks such as jQuery and React. 2) Through ReactNative and Ionic, JavaScript is used to develop cross-platform mobile applications. 3) The Electron framework enables JavaScript to build desktop applications. 4) Node.js allows JavaScript to run on the server side and supports high concurrent requests.

Python is more suitable for data science and automation, while JavaScript is more suitable for front-end and full-stack development. 1. Python performs well in data science and machine learning, using libraries such as NumPy and Pandas for data processing and modeling. 2. Python is concise and efficient in automation and scripting. 3. JavaScript is indispensable in front-end development and is used to build dynamic web pages and single-page applications. 4. JavaScript plays a role in back-end development through Node.js and supports full-stack development.

C and C play a vital role in the JavaScript engine, mainly used to implement interpreters and JIT compilers. 1) C is used to parse JavaScript source code and generate an abstract syntax tree. 2) C is responsible for generating and executing bytecode. 3) C implements the JIT compiler, optimizes and compiles hot-spot code at runtime, and significantly improves the execution efficiency of JavaScript.

JavaScript's application in the real world includes front-end and back-end development. 1) Display front-end applications by building a TODO list application, involving DOM operations and event processing. 2) Build RESTfulAPI through Node.js and Express to demonstrate back-end applications.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version
Visual web development tools
