vue 父組件調用子組件的方法
父組件:
html:
<component-name ref="componentref"></component-name> //子組件名稱
js:
this.$refs.componentref.show();//在你需要的地方,調用即可
子組件:
methods:{ show(){ console.log('我是子組件方法,你調用到我了哦'); } }
父組件:
html:
<component-name ref="componentref"></component-name> //子組件名稱
js:
this.$refs.componentref.show();//在你需要的地方,調用即可
子組件:
methods:{ show(){ console.log('我是子組件方法,你調用到我了哦'); } }
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。