# vue3-admin-manage **Repository Path**: sephriese/vue3-admin-manage ## Basic Information - **Project Name**: vue3-admin-manage - **Description**: No description available - **Primary Language**: Unknown - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-05-30 - **Last Updated**: 2024-05-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Vue 3 + Vite This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 ` ``` ``` // vite.config.js import { defineConfig } from 'vite' import ViteImages from 'vite-plugin-vue-images' export default defineConfig({ plugins: [ ViteImages({ dirs: ['src/assets/image'] // 指明图片存放目录 }) ] }) ``` 直接使用就好了,名字的大小写不敏感 ``` ``` # 构建vant 样式库 ## 按需引入 npm i @vant/auto-import-resolver unplugin-vue-components -D 具体配置项 ``` // vite.config.ts import vue from '@vitejs/plugin-vue' import Components from 'unplugin-vue-components/vite' import { VantResolver } from '@vant/auto-import-resolver' export default { plugins: [ vue(), Components({ resolvers: [VantResolver()] }) ] }; ``` 另外,根据官方文档 需要 额外引入 函数组件,可以定义一个文件,在main文件中引用,具体的组件是 Toast,Dialog,Notify 和 ImagePreview # permission 中调用function promise, 使用then的方式会报错 router.beforeEach 中调用 store中的user对象实例中的方法,涉及到一些方法,比如getUserInfo的时候,我使用了.then的方式,就是会报错,`The "next" callback was never called inside of` 大概是在function中需要去调用next来返回,但是我实际是有用到 next 回调的,不知道为什么没有找到,一直找不到原因,但是换成 async await就可以了,之后看一下源码找一下原因, 在vue-router 中,调用了 guardToPromiseFn方法,其中校验了回调函数的使用方式是否一致,如果都是 await,就保持一至,就不会发出警告。 注释是 // wrapping with Promise.resolve allows it to work with both async and sync guards 检测方法如下 ``` // wrapping with Promise.resolve allows it to work with both async and sync guards const guardReturn = guard.call(record && record.instances[name], to, from, (process.env.NODE_ENV !== 'production') ? canOnlyBeCalledOnce(next, to, from) : next); let guardCall = Promise.resolve(guardReturn); if (guard.length < 3) guardCall = guardCall.then(next); if ((process.env.NODE_ENV !== 'production') && guard.length > 2) { const message = `The "next" callback was never called inside of ${guard.name ? '"' + guard.name + '"' : ''}:\n${guard.toString()}\n. If you are returning a value instead of calling "next", make sure to remove the "next" parameter from your function.`; if (typeof guardReturn === 'object' && 'then' in guardReturn) { guardCall = guardCall.then(resolvedValue => { // @ts-expect-error: _called is added at canOnlyBeCalledOnce if (!next._called) { warn(message); return Promise.reject(new Error('Invalid navigation guard')); } return resolvedValue; }); } else if (guardReturn !== undefined) { // @ts-expect-error: _called is added at canOnlyBeCalledOnce if (!next._called) { warn(message); reject(new Error('Invalid navigation guard')); return; } } } ```