vue3.x 之 reactive

<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对象

你可能感兴趣的:(vue3.0,vue.js,typescript)