前面已使用vue-cli新建了一個vue項目,參考 使用命令行建立一個vue項目的所有命令及結果css
首先看下新建項目的頁面和代碼,有部分修改,可忽視,以下圖:html
而後咱們在頁面添加sass的代碼:vue
修改完保存後當即就報錯了:node
在使用scss以前,咱們首先須要安裝相關的插件: 這裏參考的是:連接( vue 項目 使用sass )webpack
$ npm install node-sass --save-dev
> node-sass@4.9.0 install F:\05 poverty alleviation project\poverty\node_modules\node-sass
> node scripts/install.js
Cached binary found at D:\nodejs\node_cache\node-sass\4.9.0\win32-x64-57_binding.node
> node-sass@4.9.0 postinstall F:\05 poverty alleviation project\poverty\node_modules\node-sass
> node scripts/build.js
Binary found at F:\05 poverty alleviation project\poverty\node_modules\node-sass\vendor\win32-x64-57\binding.node
Testing binary
Binary is fine
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ node-sass@4.9.0
added 73 packages from 83 contributors and audited 33411 packages in 40.38s
found 16 vulnerabilities (1 low, 10 moderate, 4 high, 1 critical)
run `npm audit fix` to fix them, or `npm audit` for details
$ npm install sass-loader --save-dev
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ sass-loader@7.0.3
added 9 packages from 17 contributors and audited 33431 packages in 15.084s
found 16 vulnerabilities (1 low, 10 moderate, 4 high, 1 critical)
run `npm audit fix` to fix them, or `npm audit` for details
安裝完從新啓動項目,以下圖,咱們看到頁面是能夠正常顯示了,用scss寫的樣式也起了做用哦 :)web
這裏不一樣於參考連接的是,不須要配置參考文說到的webpack.base.config.js,但是也能正常使用了。vue-cli
而安裝上面的插件也是一次性就安裝成功的,沒有出現別的問題。npm
誰知道緣由的能夠留言哦,新手不是很懂這些配置文件。sass