摘要:
ue3转变 从 vue3 开始,由 setup 替代 vue2 data、methods、watch等 ,这样可以避免一个功能的代码逻辑拆分到各个属性中而变得难以阅读 vue3 setup 的这种写法可以更好的使用 TypeScript注意事项: setup 函数里面不可以使用 this, 因为se 阅读全文
摘要:
Ref <template> <h1>{{name}}</h1> <h1>{{age}}</h1> <button @click="sayName">按钮</button> </template> <script lang="ts"> import {ref,computed} from 'vue' 阅读全文
摘要:
import {onMounted, ref} from 'vue' export default function useMouse() { let x = ref(0) let y = ref(0) onMounted(() => { window.addEventListener('mouse 阅读全文
摘要:
// useCount.js import {ref,reactive,computed} from 'vue' export default function useCount() { // 简单数据定义及使用 let count = ref(0) function addCount() { co 阅读全文
摘要:
一、reactive reactive 用于为对象添加响应式状态。接收一个js对象作为参数,返回一个具有响应式状态的副本。 获取数据值的时候直接获取,不需要加.value 参数只能传入对象类型 import { reactive } from 'vue' // 响应式状态 const state = 阅读全文