1、代码如下:
<template> <h3>内联事件处理群</h3> <button @click="addCount1">Add</button> <p>{{ count1 }}</p> <button @click="addCount2('hello')">按钮</button> <p>{{ count2 }}</p> </template> <script> export default { data() { return { count1: 0, count2: 0 } }, methods: { addCount1() { //读取到data里面的数据方案:this.count this.count1++; }, addCount2(msg) { //读取到data里面的数据方案:this.count console.log(msg); this.count2++; } } } </script>
2、效果如下:
标签:传参,事件处理,按钮,Vue3,count1,count2,data From: https://www.cnblogs.com/tianpan2019/p/18352524