1. vue的生命周期函数有哪些?
beforeCreate
created
beforeMount
mounted
beforeUpdate
updated
beforeDestroy
destroyed
2. vue的通信方式有哪些?
props
: 父子通信层层传递$refs
: 通过ID引用访问子组件实例$parents/$children
: 子组件访问父组件实例/获取当前实例的子组件provide/inject
: 祖先组件向后代组件注入依赖eventBut
: 在互通信的两组件中引入同一个新的vue实例vuex
3. Vue.nextTick
作用是什么?
- 在DOM更新完成后调用传入的回调函数
- 因为Vue中数据变化后,Vue将
异步
执行DOM更新
4. Vue双向数据绑定原理是什么?
- 使用数据劫持 + 发布订阅模式实现
- Vue2使用
Object.defineProperty()
- Vue3使用
Proxy