一:安装及使用
1.在当前目录下,安装依赖
$ cd mpvue $ npm install
2.安装sass的依赖包
npm install --save-dev sass-loader //sass-loader依赖于node-sass npm install --save-dev node-sass
3.在build文件夹下的webpack.base.conf.js的rules里面添加配置
{ test: /\.sass$/, loaders: ['style', 'css', 'sass'] }
4.在APP.vue中修改style标签
<style lang="scss"> $background:#ccc; html{background:$background;} </style>
二:引入外部sass
img.scss,文件路径'static/img.scss'
,内容如下
$bgjpg : 'http://baidu.com' $color : red
APP.vue中引入
<style lang="scss"> @import "static/img.scss"; html{ background-image: url($bgjpg); color: $color } </style>