stylus定义全局变量
2018-12-08 本文已影响0人
彬彬彬boboc
1、新建name.styl 文件
$bgcolor=#00bcd4
在.vue文件中引入.styl文件
<style lang="stylus" scoped>
@import "../../name.styl"
.text
background:$bgcolor
</style>
2、定义全局样式块
在.styl定义一个方法
ellipsis()
overflow:hidden
white-space:nowrap
text-overflow:ellipsis
<style lang="stylus" scoped>
@import "../../name.styl" //此处可以简写成@import "~@/assets/stylus/name.styl" @代表src目录下如果要在style标签总引
入文件@前面要加“~”
.text
background:$bgcolor
ellipsis()
</style>