您现在的位置是:主页 > news > wordpress建小说网站/百度商业平台

wordpress建小说网站/百度商业平台

admin2025/5/18 17:35:33news

简介wordpress建小说网站,百度商业平台,淘宝详情页设计一个多少钱,徐州煤棚网架公司$emit 我们知道&#xff0c;父组件是使用 props 传递数据给子组件&#xff0c;但如果子组件要把数据传递回去&#xff0c;应该怎样做&#xff1f;那就是自定义事件&#xff01; 使用 v-on 监听事件 使用 $emit 触发事件 $emit(事件名&#xff0c;传递的数据) <div id"a…

wordpress建小说网站,百度商业平台,淘宝详情页设计一个多少钱,徐州煤棚网架公司$emit 我们知道&#xff0c;父组件是使用 props 传递数据给子组件&#xff0c;但如果子组件要把数据传递回去&#xff0c;应该怎样做&#xff1f;那就是自定义事件&#xff01; 使用 v-on 监听事件 使用 $emit 触发事件 $emit(事件名&#xff0c;传递的数据) <div id"a…

$emit

我们知道,父组件是使用 props 传递数据给子组件,但如果子组件要把数据传递回去,应该怎样做?那就是自定义事件!

使用 v-on 监听事件
使用 $emit 触发事件
$emit(事件名,传递的数据)

<div id="app"><p>{{todo}}</p><mycomponent @inset="adds"></mycomponent><mycomponent @inset="adds"></mycomponent>
</div>
<script>  
var componentA = {data: function(){return{count: 0}},template: '<button @click="add" type="button">{{count}}</button>',methods: {add: function(){this.count++;// 触发自定义事件this.$emit('inset', this.count)}}
}
new Vue({el: '#app',data: {todo: 0},components: {// 引用组件'mycomponent': componentA},methods: {adds: function(num){this.todo++;console.log(num)}}
})
</script>

1321525-20180609073937975-458615023.gif

转载于:https://www.cnblogs.com/xiaobaiv/p/9158352.html