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返回是的

展開:

 成果:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM