美文网首页
stylus定义全局变量

stylus定义全局变量

作者: 彬彬彬boboc | 来源:发表于2018-12-08 10:07 被阅读0次

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>

相关文章

网友评论

      本文标题:stylus定义全局变量

      本文链接:https://www.haomeiwen.com/subject/ulofhqtx.html