[英]How do I install vue router plugin with Vue CLI 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.
有人可以解释为什么这不起作用吗?
PS我也尝试过vue add @vue/router
,我得到相同的消息。
我懂了! 谢谢@dnhyde的建议。 但是,如果您实际上想将其安装为插件,则需要将Vue CLI更新到3.0.0-rc.10。 使用以下命令执行此操作: npm i -g @vue/cli
。
嗨,我遇到了类似的问题,在我的情况下,添加Vue路由器的最佳方法是从vue create my-project
命令开始选择它。 或者,您可以按照为您创建的模板vue-cli手动在主目录中手动添加router.js文件和Vue.use(router)
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.