<div id="root">
<test :value="value" @clickTest="testClick"></test>
</div>
<script>
var test = {
props: ["value"],
template: "<div @click='handleClick'>{{value}}</div>",
methods: {
handleClick: function () {
this.$emit("clickTest", 123);
},
},
};
var vm = new Vue({
el: "#root",
data: {
value: "测试",
},
components: {
test,
},
methods: {
testClick: (test) => {
console.log(test);
},
},
});
</script>
课程紧跟Vue3版本迭代,企业主流版本Vue2+Vue3全掌握
了解课程