vue如何在父組件指定點(diǎn)擊事件后向子組件傳遞參數(shù)并調(diào)用子組件的事件?
發(fā)布日期:2020-11-26瀏覽次數(shù):1397 來源:福州網(wǎng)站建設(shè)
父組件
<template>
<div>
<el-button type="text" @click="sonFun">useSon</el-button>
<sonV ref='sonV' :mes="sonData"></sonV>
</div>
</template>
<script>
import sonV from './test.vue';
export default {
components: {
sonV
},
data() {
return {
sonData: ''
};
},
medthods: {
sonFun() {
this.sonData = '123';
let param = 456;
this.$refs.sonV.sonFun(param);
}
}
};
</script>
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
子組件
<template>
<div>{{mes}}</div>
</template>
<script>
export default {
props:['mes'],
data(){
return{
}
},
methods:{
sonFun(param){
console.log(this.mes)
console.log(param)
}
}
}
</script>
以上是由福州網(wǎng)站建設(shè)的小編為你分享了"vue如何在父組件指定點(diǎn)擊事件后向子組件傳遞參數(shù)并調(diào)用子組件的事件?"文章,如果你在這方面有什么問題,隨時(shí)聯(lián)系我們