您当前的位置: 首页 > 

@大迁世界

暂无认证

  • 3浏览

    0关注

    739博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

17.在vue中怎么动态样式类的几种方式

@大迁世界 发布时间:2022-08-28 22:22:20 ,浏览量:3

这节课,我们来看下 Vue 中动态设置样式的几种方式。在 Vue 中有专门为 classstylev-bind 用法提供了特殊的功能增强。除了字符串外,表达式的值也可以是对象或数组。

我经常用的一种模式就是使用 boolean 标志,如下所示:


  
当 disabled 为 true 时,这个组件被禁用了。
.disabled-component { background-color: gray; color: darkgray; cursor: not-allowed; }

这里通过一个变量或计算属性 disabled 来开启或关闭 'disabled-component' ,当 disabledtrue 时,开启样式 'disabled-component',否则关闭,这样就能简单动态的设置样式了。

disabled() 
关注
打赏
1664287990
查看更多评论
立即登录/注册

微信扫码登录

0.0407s