重點通過這句話給對象添加屬性:
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返回是的
展開:
成果: