javascript - 如何使用 Vue CLI 3 安装 vue 路由器插件?

标签 javascript vuejs2 vue-router

所以我一直在使用 Vue CLI 3.0.0rc8 设置项目,它是一个非常棒的工具,但我遇到了问题。我正在尝试为我的项目安装路由器插件,但是当我使用 vue add router 时,我得到了这个:

(node:2706) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'routerHistoryMode' of undefined
at module.exports (/home/joshua/programs/firstwebapp/frontend/node_modules/@vue/cli-service/generator/router/index.js:10:26)
at Generator.plugins.forEach (/home/joshua/.node_modules_global/lib/node_modules/@vue/cli/lib/Generator.js:96:7)
at Array.forEach (<anonymous>)
at new Generator (/home/joshua/.node_modules_global/lib/node_modules/@vue/cli/lib/Generator.js:94:13)
at Function.runGenerator (/home/joshua/.node_modules_global/lib/node_modules/@vue/cli/lib/invoke.js:111:21)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:2706) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:2706) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

有人可以解释为什么这不起作用吗?

P.S. 我也试过 vue add @vue/router 我得到了同样的信息。

最佳答案

我知道了!感谢@dnhyde 的建议。但是如果你真的想把它作为插件安装,你需要将 Vue CLI 更新到 3.0.0-rc.10。使用此命令执行此操作:npm i -g @vue/cli

关于javascript - 如何使用 Vue CLI 3 安装 vue 路由器插件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51691746/

相关文章:

javascript - 为什么 'this'指的是对象 'obj'不是全局对象

php - 如何在 vue js 中使用数字和正则表达式进行验证?

jquery - 使用 vuejs v2.0+ Bootstrap v3.3.7 时遇到 VueJS 类绑定(bind)问题

vuejs2 - 打开外部 URL

vuejs2 - 具有 ServiceStack 路由回退和 Api 前缀的 Vue.js 路由器历史记录模式

javascript -\getting 附加在 JSON 响应中。我应该如何删除这个

javascript - 如何在 jQuery 图像 slider 中播放视频?

javascript - 从 JSON 获取数据

vue.js - VUEJS-如何从url中删除参数

javascript - vue-router 带有名称的路由不存在