vue2安装less
1. 安装scss
npm install node-sass --save-dev 安装不上执行 npm install node-sass@4.14.1
npm install sass-loader --save-dev 安装不上执行 npm install sass-loader@7.0.2 --save-dev
2. 在build文件中找到webpack.base.conf.js, 配置如下:
{ //上面的不修改,这是sass的配置
test: /\.scss$/,
loaders: ['style', 'css', 'sass']
},
3 在 .vue 的编程页面上,style上加 lang='scss'
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang='scss'>
.hello {
h1,
h2 {
font-weight: normal;
background-color: red;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
}