下面是一个Vue3 Composition API 中使用Vuex的实例todoList,用到了state,mutations,actions,可以把自己之前用vue2的旧语法改写成vue3的语法,使用setup,ref, reactive, toRefs,useStore等,
完整代码指路:github: color-library;
原文出处:Vue3 Composition API 中使用 Vuex;
原文地址同时也是我的博客园地址,欢迎关注,会不定期更新~
<!-- todoList.vue -->
<template>
<div class="todo-list-wrap">
<h2>{
{ title }}</h2>
<div class="name-wrap">
<h3>{
{ name }}</h3>
<el-button @click="handleChangeName">
修改
</el-button>
<el-button @click="handleRestoreName">
还原
</el-button