source

Vue CLI 3에서 vue 라우터 플러그인을 설치하려면 어떻게 해야 합니까?

factcode 2022. 9. 21. 23:23
반응형

Vue CLI 3에서 vue 라우터 플러그인을 설치하려면 어떻게 해야 합니까?

그래서 저는 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.

이게 왜 안 되는지 누가 설명 좀 해주시겠어요?

추신. 나도 노력했어.vue add @vue/router같은 메시지를 받습니다.

알았어요.제안해 주셔서 @dnhyd에게 감사드립니다.그러나 실제로 플러그인으로 설치하려면 Vue CLI를 3.0.0-rc.10으로 업데이트해야 합니다.이 작업을 수행하려면 다음 명령을 사용합니다.npm i -g @vue/cli.

안녕하세요, 저도 같은 문제가 있었습니다.제 경우 Vue 라우터를 추가하는 가장 좋은 방법은 처음부터 Vue 라우터를 선택하는 것입니다.vue create my-project명령어를 입력합니다.또는 router.js 파일 및 Router.js 파일을 수동으로 추가할 수도 있습니다.Vue.use(router)vue-cli가 생성하는 템플릿에 대한 자세한 내용은 다음과 같습니다.

언급URL : https://stackoverflow.com/questions/51691746/how-do-i-install-vue-router-plugin-with-vue-cli-3

반응형