vue學習筆記18 propsData


propsData 不是和屬性有關,他用在全局擴展時進行傳遞數據。

先寫一個全局擴展

var header_a =  Vue.extend({

  template:`{{message}}   傳值 {{ a }}`,

  data:function(){

    return {

      message:"內容"

    }

  },  

  props:['a']

})

 

掛載   new header_a().$mount('header')

 

這時如果想傳遞值。就要用propsData

1.在全局擴展里加入props進行接收。  new header_a(propsData:{a:1}).$mount('header')

2.傳遞時用propsData進行傳遞。props:[‘a’]

3.用插值的形式寫入模板。{{ a }}    

 


免責聲明!

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



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