在 Vue.js 中使用 stylus 预处理器

  1. 安装 stylus,stylus-loader 依赖
npm i stylus -D
npm i stylus-loader -D

因为是预编译,只需在开发环境下依赖,所以不用 -S 了
注意:安装完成之后不要忘了重新启动项目

  1. 在 vue 组件中使用 stylus
    lang="stylus":使用 stylus 语法
    scoped:scoped 范围内的 css 样式只能影响所在组件自己
<style lang="stylus" scoped>
  .item-info
    padding: .1rem
    .item-title
      line-height: .54rem
      font-size: .32rem
      ellipsis()
    .item-desc
      line-height: .4rem
      color: #ccc
</style>

猜你喜欢

转载自blog.csdn.net/qq_40925105/article/details/86485230