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; //得到的数据赋值给laws

this.laws.forEach((r)=>{ //循环遍历laws对象 分别一一赋值新对象 this.$set(r,'upshow',false); //重点是这句话。(对象,属性,属性值) }) }) },

 

此时law返回是的

展开:

 成果:

 

posted @ 2019-01-14 10:48  Du.Du  阅读(5233)  评论(0编辑  收藏  举报