Observer(__ob__: Observer) 对象添加属性

重点通过这句话给对象添加属性:

this.$set(r,'upshow',false);

在data中定义laws来装从接口中请求到数据

 data(){
            return{
                laws:[],//法律依据
            }
 },
 _getAttachment(){
                getAttachment(
                    {attachment_id: this.attachment_id},
                    {Authorization: this.access_token}
                ).then( (res)=>{this.laws = res.content.laws;  //得到的数据赋值给lawsthis.laws.forEach((r)=>{ //循环遍历laws对象 分别一一赋值新对象

                        this.$set(r,'upshow',false); //重点是这句话。(对象,属性,属性值)
                    })
                })
            },

此时law返回是的

展开:

 成果:

猜你喜欢

转载自www.cnblogs.com/dudu123/p/10265660.html