Loading

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之后这个数据就是响应式了, 不然用不了

posted @ 2023-10-21 16:13  mingBolg  阅读(53)  评论(0)    收藏  举报