export 'default' (imported as 'VueRouter') was not found in 'vue-router' ‘’
时间: 2023-12-13 14:23:21 浏览: 178
这个错误通常发生在使用 Vue Router 时。它表示未正确导入 VueRouter,默认导入的名称应为 'VueRouter'。请确保在导入 Vue Router 时使用正确的导入语法,并将其分配给变量名 'VueRouter'。例如:
```javascript
import VueRouter from 'vue-router';
// 或者
const VueRouter = require('vue-router').default;
```
请注意,Vue Router 的最新版本可能会有所不同,因此请根据您的 Vue Router 版本进行必要的更改。
相关问题
WARN "css.modules" option in vue.config.js is deprecated now, please use "css.requireModuleExtension" instead. INFO Starting development server... 98% after emitting CopyPlugin WARNING Compiled with 17 warnings 09:43:57 warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'computed' was not found in 'vue' warning in ./src/router/index.js "export 'default' (imported as 'VueRouter') was not found in 'vue-router' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'defineComponent' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'getCurrentInstance' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'h' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'inject' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'nextTick' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'onActivated' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'onDeactivated' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'onUnmounted' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'provide' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'reactive' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'ref' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'shallowRef' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'unref' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'watch' was not found in 'vue' warning in ./node_modules/vue-router/dist/vue-router.mjs "export 'watchEffect' was not found in 'vue'这个报错因为什么
这个报错是因为在使用Vue Router时,导入的Vue Router版本与当前项目中的Vue版本不匹配导致的。具体来说,Vue Router中使用了Vue 3的语法而当前项目中使用的是Vue 2,所以会出现一些语法上的错误。解决方法是将Vue Router更新到与当前项目中使用的Vue版本相匹配的版本。
export 'default' (imported as 'VueRouter') was not found in 'vue-router'
这个错误通常出现在使用 Vue Router 时,导入语句中的默认导出无法找到。可能有几种原因导致这个问题:
1. 确保你已经正确安装了 Vue Router。使用 npm 或者 yarn 进行安装,并且在项目中导入 Vue Router。
2. 检查导入语句是否正确。在你的代码中,确保导入语句中的路径和导入的模块名是正确的。你可以尝试使用相对路径或者绝对路径来导入 Vue Router。
3. 检查你的 Vue Router 版本是否与你的项目兼容。不同的 Vue 版本可能需要不同的 Vue Router 版本。请确保你正在使用与你的 Vue 版本兼容的 Vue Router 版本。
如果你已经检查了以上几点,还是无法解决问题,可以尝试重新安装 Vue Router 或者更新你的依赖版本。此外,还可以尝试参考 Vue Router 的官方文档或者社区中的解决方案来解决这个错误。
阅读全文