src/store/modules/nav.js
import {defineStore} from 'pinia'; import {handleTree} from '@/utils/ruoyi' import {list} from "@/api/nav/node"; const store = defineStore( 'nav', { state: () => ({ nodeList: [] }), actions: { GetTree() { return new Promise((resolve, reject) => { list().then(res => { this.nodeList = handleTree(res.data, 'id'); resolve() }).catch(error => { reject(error) }) }) }, } }) export default store
xx.vue:使用
经过computed处理过后的nodeList才是响应式数据,而且会监视着store中nodeList的变化的
标签:nodeList,res,学习,nav,vue3,import,store From: https://www.cnblogs.com/joeblackzqq/p/18062037