stylus安裝
npm install stylus --save
npm install stylus-loader --save
stylus使用
一、語法不再需要括號,相比之前語法簡潔了很多。
<style lang="stylus" scoped>
.header
display: flex
line-height: .86rem
background: $bgColor
color: #fff
</style>
二、可以創(chuàng)建.styl擴展名的文件,然后在Vue組件的中引入,達到公用一些樣式的目的。
例:在項目中使用通用背景色,在/src/assets/styles中創(chuàng)建varibles.styl,在其中寫入代碼:
$bgColor = #00bcd4
然后在組件中使用,
先引入varibles.styl,記住~一定要加:
@import '~styles/varibles.styl';
使用:
.header
background: $bgColor