vue3 ref的简单使用
<script setup> import { ref } from 'vue' const msg = ref(1) const clickMsg = () =>{ msg.value++; console.log(2223323)} const clickMsgjj = () =>{ msg.value--; console.log(2223323)} </script> <template> <div>{{ msg }}</div><br> <button @click="clickMsg" >按钮++</button> <button @click="clickMsgjj" >按钮--</button> </template> <style scoped> </style>
ref之后这个数据就是响应式了, 不然用不了

浙公网安备 33010602011771号