1、在安装了node.js的前提下,使用以下命令
npm install --g vue-cli
执行命令后:
>npm install --g vue-cli
npm WARN deprecated vue-cli@2.9.6: This package has been deprecated in favour of @vue/cli
npm WARN deprecated coffee-script@1.12.7: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
C:\Users\12589\AppData\Roaming\npm\vue-init -> C:\Users\12589\AppData\Roaming\npm\node_modules\vue-cli\bin\vue-init
C:\Users\12589\AppData\Roaming\npm\vue -> C:\Users\12589\AppData\Roaming\npm\node_modules\vue-cli\bin\vue
C:\Users\12589\AppData\Roaming\npm\vue-list -> C:\Users\12589\AppData\Roaming\npm\node_modules\vue-cli\bin\vue-list
+ vue-cli@2.9.6
added 241 packages from 206 contributors in 199.066s
执行完命令一直卡在第三行,第二天一早起来再次执行,结果行了。。。
2、在将要构建项目的目录下
vue init webpack myproject(项目目录名称)
>vue init webpack myproject1
? Project name myproject1
? Project description A Vue.js project
? Author wjp <125890628@qq.com>
? Vue build standalone
? Install vue-router? Yes
? Use ESLint to lint your code? Yes
? Pick an ESLint preset Standard
? Set up unit tests No
? Setup e2e tests with Nightwatch? No
? Should we run `npm install` for you after the project has been created? (recommended) npm
vue-cli · Generated "myproject1".
上面的步骤有时候挺慢
npm的镜像替换成淘宝
1查看npm仓库
npm get registry
2.替换地址
npm config set registry http://registry.npm.taobao.org/
成功的结果如下
To get started:
cd myproject1
npm run dev
Documentation can be found at https://vuejs-templates.github.io/webpack
执行上面两条命令
DONE Compiled successfully in 3149ms 8:12:16
I Your application is running here: http://localhost:8080
npm run build 打包发布到网上
多了dist文件,访问时css,js加载不上
修改index.html的/为./就可以了