页面渲染,有时真的不知道为什么会这样子 一个编辑的页面,有个数据渲染总是渲染不了。发现 show(row){ this.form = Object.assign({}, row) this._getById(this.form.id) this.form.users= this.form.users } 代码这样子,发现渲染users的时候,怎么都渲染不出来。通过debug发现有数据的,但是不知道怎么解决。 后面就在改成这样子,解决了 show(row){ this.form = Object.assign({}, row) this._getById(this.form.id) this.form.users= this.form.users //在设置一次当前数据 this.$nextTick(() => { this.form = Object.assign({}, this.form) }) }
注意: 这个是官网的解释: Vue.nextTick( [callback, context] ) 在下次 DOM 更新循环结束之后执行延迟回调。在修改数据之后立即使用这个方法,获取更新后的 DOM。
然后users定义的数组,在debug中,发现会从arr转成NodeList,
array和NodeList不是一个东西。