vue 给组件绑定原生事件
作者:互联网
通过事件修饰符@click.native 给组件绑定原生事件
父组件home
<template>
<div>
<h1>home组件</h1>
<child1 @click.native="change(2)"></child1>
<p>total: {{total}}</p>
</div>
</template>
<script>
import child1 from './Child1'
export default {
data() {
return {
total: 0
}
},
components: {
child1
},
methods: {
change(step) {
this.num = this.num + step
this.total = this.total + step
}
}
}
</script>
子组件 child1
<template>
<div>
<h1>child1组件</h1>
<p>num:{{num}}</p>
</div>
</template>
<script>
export default {
props: ['msg'],
data() {
return {
num : 0
}
},
}
</script>
标签:child1,vue,绑定,step,num,export,组件,total 来源: https://blog.csdn.net/qq_37550440/article/details/113795507