Vue面试问题

  1. vue响应式原理
    参考: https://www.cnblogs.com/fundebug/p/responsive-vue.html
    Object.defineProperty实现
    Vue通过设定对象属性setter/getter方法来监听数据的变化,通过getter进行依赖收集,
    而每个setter方法就是一个观察者,在数据变更的时候通知订阅者更新视图.

  2. vue的生命周期
    beforeCreate,created
    beforeMount,mounted
    beforeUpdate,updated
    activated,deactivated
    beforeDestory,destoryed
    activated: 当页面重新显示的时候执行. 搭配keep-alive,localStorage和临时变量做页面性能优化.
    deactivated: 当页面即将被隐藏或替换其他页面时执行. 可以用来解绑在activated上绑定的全局事件.
    mounted: 是挂载vue实例后的钩子函数,钩子在主页挂载时执行一次. 如果没有缓存的话,再次回到主页时,此函数还会执行.
    activated: 是组件被激活后的钩子函数,每次回到页面都会执行.

  3. vue $nextTick原理,事件机制
    参考: https://www.jianshu.com/p/a7550c0e164f

  4. 组件传值
    参考: https://juejin.cn/post/6844903845642911752
    var Event = new Vue()
    Event.$ emit(事件名, 数据)
    Event.$ on(事件名, data => { })

  5. vuex
    参考: https://vuex.vuejs.org/zh/

  6. vue-router
    参考: https://rou

猜你喜欢

转载自blog.csdn.net/hujian66/article/details/124600170