Appearance
Vuex-store 
可替换
类似的插件有pinia可替代
- 使用
vue InjectionKey创建key组合式API管理 - 将
vuex中四部分进行模块拆分 state的类型写在src/types目录下
API请求封装 
/src/store/API/quest.ts再次对uni.quest的封装- 请求回调的处理,添加loading等公用模块
 - 打印错误日志、登录状态的校验
 
store的运用 
Vue单文件规范下使用 
vue
<script setup lang="ts">
	// 引入与注册
	import { useStore } from '@/store';
  const store = useStore()
  
  // getters 使用
  const storeData = store.getters.getHospitalInfo
  
  // actions 异步请求的使用
  const getSomethingData = (index: number) => {
    store.dispatch('getSomethingData').then(res => {
      uni.showToast({
        title: `index为${index}`,
        icon: 'none'
      })
    })
  }
</script>
<template>
	<view>{{storeData}}</view>
</template>在state中注册的数据可直接都文件中使用
vue
<script setup lang="ts">
	// 引入 useStore {...}
	const projectName = store.state.projectName
	console.log(projectName)
</script>
好大夫前端技术文档