vue3.x 之 reactive

it_dog_zhang發表於2020-10-14
<template>
  <div>
    {{ count.value }}
    <button @click.prevent="Add">Add</button>
  </div>
</template>

<script lang="ts">
import { defineComponent, reactive } from 'vue';

export default defineComponent({
  name: 'VueTest',
  setup() {
    const count = reactive({ value: 0 });
    function Add() {
      count.value += 1
    }
    return {
      count,
      Add
    };
  }
});
</script>

注:reactive 接收是一個object物件

相關文章