在命令行中输入 npm install -g cnpm --registry=http://registry.npm.taobao.org(国内太慢使用淘宝镜会快很多)
cnpm install -g vue-cli
vue init webpack firstVue
cd firstVue
npm install
npm run dev
安装less依赖,
命令npm install less less-loader --save
修改webpack.config.js文件,配置loader加载依赖,让其支持外部的less,在原来的代码上添加
{ test: /\.less$/, loader: "style-loader!css-loader!less-loader", },
<style lang="less" scoped></style>
1.项目里安装vux
npm install vux --save
2.安装vux-loader(vux2必须结合vux-loader使用,本文也只是介绍vux2的配置)
npm install vux-loader --save-dev
3.安装less-loader
npm install less less-loader --save-dev
安装完成记得在webpack.base.conf.js里做如下配置,在extensions里加入less
vux2必须配合vux-loader
使用, 请在build/webpack.base.conf.js
里参照如下代码进行配置:
const vuxLoader = require('vux-loader')
const webpackConfig = originalConfig // 原来的 module.exports 代码赋值给变量 webpackConfig
module.exports = vuxLoader.merge(webpackConfig, {
plugins: ['vux-ui']
})
# 全局安装 vue-cli
$ cnpm install --global vue-cli
# 创建一个基于 webpack 模板的新项目
$ vue init webpack my-project
# 这里需要进行一些配置,默认回车即可
This will install Vue 2.x version of the template.
For Vue 1.x use: vue init webpack#1.0 my-project
? Project name my-project
? Project description A Vue.js project
? Author runoob <test@runoob.com>
? Vue build standalone
? Use ESLint to lint your code? Yes
? Pick an ESLint preset Standard
? Setup unit tests with Karma + Mocha? Yes
? Setup e2e tests with Nightwatch? Yes
vue-cli · Generated "my-project".
To get started:
cd my-project
npm install
npm run dev
Documentation can be found at https://vuejs-templates.github.io/webpack
$ cd my-project
$ cnpm install
$ cnpm run dev
DONE Compiled successfully in 4388ms
> Listening at http://localhost:8080