首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何使用vue CLI 3安装Vue路由器插件?

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

Stack Overflow用户
提问于 2018-08-05 13:52:37
回答 2查看 1.4K关注 0票数 3

所以我一直在使用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,我得到了同样的信息。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-08-05 23:19:40

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

票数 3
EN

Stack Overflow用户

发布于 2018-08-05 19:10:58

嗨,我遇到了类似的问题,在我的例子中,添加Vue路由器的最好方法是从start with vue create my-project命令中选择它。或者,您可以按照为您创建的模板vue-cli在main中手动添加router.js文件和Vue.use(router)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51691746

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档