vue——父组件调用子组件

vue

<template>

<div>

child1

</div>

</template>

<script>

export default {

name: "child1",

props: "msg",

methods: {

handleParentClick(e) {

console.info(e)

}

}

}

</script>

parent.vue

<template>

<div>

<button v-on:click="clickParent">点击</button>

<child1 ref="child1"></child1>

</div>

</template>

<script>

import Child1 from './child1';

export default {

name: "parent",

components: {

child1: Child1

},

methods: {

clickParent() {

// this.$refs.child1.$emit('click-child', "high");

this.$refs.child1.handleParentClick("ssss");

}

}

}

</script>

以上是 vue——父组件调用子组件 的全部内容, 来源链接: utcz.com/z/380566.html

回到顶部