Observer(__ob__: Observer) 對象添加屬性
阿新 • • 發佈:2019-01-14
then aws ups 添加屬性 foreach 得到 通過 bsp att
重點通過這句話給對象添加屬性:
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返回是的
展開:
成果:
Observer(__ob__: Observer) 對象添加屬性