Vue interview questions (1)

Basics

  • css only works in the current component
  • The difference between v-if and v-show
  • The difference between $route and $router
  • What are the two cores of vue.js
  • Vue commonly used instructions
  • Vue commonly used modifiers
  • Can v-on bind multiple methods?
  • The role of the key value in vue
  • What is vue calculated attribute
  • Single page applications such as vue and their advantages and disadvantages
  • How to define the dynamic routing of vue-router? How to get the passed value
  • The difference between watch and computed
  • Why is data in the component a function

Extension

  • Understanding of MVVM
  • The stages of the VUE life cycle
  • What is the VUE life cycle
  • The first page load will trigger those hooks
  • DOM rendering is completed in that cycle
  • Vue realizes the principle of two-way data binding
  • Passing of parameters between vue components
  • Implementation of vue routing in hash mode and history mode
  • What is vuex and how to use that functional scenario
  • Understanding of keep-alive
  • Advantages of virtual DOM
  • Deep use of vue's watch
  • The difference between mutation and action in vuex
  • What are the navigation guards in vue-router
  • Briefly describe the principle of vue diff algorithm

Common interview questions

css only works on the current component
. Write scoped in the style tag.

The difference between v-if and v-show
v-show: add dispaly block or none
v-if: conditionally render v-if is complete destruction and re-creation

The difference between $route and $router

route is the routing information object including path hash query fullPath matched name and other routing information parameters while $router is the routing instance object including the route jump method hook function

Several stages of the VUE life cycle

beforeCreate (before creation) the data observation and initialization event has not yet started
create (after creation) completes the calculation of the observation attributes and methods of the data initialization event $el attribute has not been displayed

beforeMount (before loading) is called before the start of the mount, the relevant render function is called for the first time. The example has been configured and compiled the template to generate HTML from the data and template in the data. Note that the html is not yet mounted on the page at this time

mounted (after loading) After el is replaced by the newly created vm.$el and mounted on the instance, the instance is called. The configuration has been completed. Replace the DOM object pointed to by the el attribute with the compiled HTML content above. Complete the HTML in the template Ajax interaction is performed during the process of rendering to the HTML page

beforeUpdate (before update) The call occurs before the data is updated before the virtual DOM is re-rendered and patched. The state can be further changed in this hook without triggering an additional re-rendering process.

updated (Updated) After the virtual DOM is re-rendered and patched due to data changes, the component DOM has been updated when the call is called, so DOM-dependent operations can be performed. However, in most cases, you should avoid changing the state during this period because of this possibility. Will cause an infinite update loop. The hook is not called when the server is rendered.

beforeDestroy (Before Destroy) Calling the instance before the instance is destroyed is fully available

destroy (after destruction) after the instance is destroyed, all event listeners will be removed after the call is called, and all sub-instances will also be destroyed. This hook is not called during server-side rendering.

Understanding of
keep-alive keep-alive is a built-in component of vue that can keep the state of the included components or avoid re-rendering.
After the vue2.1.0 version, keep-alive added two new attributes include (including the component’s cache) With exclude (the excluded components are not cached with priority greater than include)

Guess you like

Origin blog.csdn.net/qq_38686150/article/details/112393375