用VUE渲染数据时遇到的问题:数据模型层更新了,但是没有在view层更新,而通过console打印发现数据确实更新了,只是view层没有及时的检测到, 而我一直以来的想法就是: 既然vue实现的时数据双向绑定,那么在model层发生了变化之后为什么就没有在view层更新呢?


查阅vue官网教程得知,由于 JavaScript 的限制,Vue 不能检测以下变动的数组

Vue.set(object, key, value)方法的作用:如果对象是响应式的,确保属性被创建后也是响应式的,同时触发视图更新,这个方法主要用于避开Vue不能检测到属性被添加的限制。

网友评论