vue的自定義組件如何使用prop傳值?


父組件的編寫

<a:orgCode=orgCode ></a>

在data里面增加orgCode。

data() {
  return {
    orgCode: '037',
    },
  };
},

子組件編寫

子組件通過prop接收

props: {
  orgCode: {
    type: String,
    default: null,
  },
},

子組件使用

子組件可以通過this.orgCode進行使用。


免責聲明!

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



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