就当笔记吧:
我用Jsp模拟了一个List,Vue版本是2.5.16,实现过程中有个地方需要说明下:
1.直接按照视频里用created: function(){this.list=JSON.parse(this.list)}会报警告信息:Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop’s value. Prop being mutated: “list”。意思是说避免直接修改prop,因为其值会在父组件重新渲染时被覆盖,相关逻辑应使用基于该prop值的data或computed实现。
可以改为:data: function () {return {mutableList: JSON.parse(this.list)}
或者:computed: {listJson: function(){return JSON.parse(this.list);}
我找到了官方文档说明的链接如下:https://cn.vuejs.org/v2/guide/migration.html#修改-Props-弃用