账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    动态改变class,值变了class添加不上
    • 2019-09-27 00:00
    • 11
    41
    0
    <li v-for="item of statisticsList"
        :key="item.id"
        :class="{'active':statistics===item.id}"
        @click="changeStatistics(item.id)">{{item.name}}</li>
    changeStatistics(id){
        this.statistics = id
    },
    li {
        width: 80px;
        height: 31px;
        background: url("./image/btn-bg.png") no-repeat;
        background-size: 80px 35px;
        display: inline-block;
        position: relative;
        font-size: 18px;
        font-weight: 400;
        color: #fff;
        text-align: center;
        padding-top: 0;
        cursor: pointer;
    
        &:hover, &.active {
            background: url("./image/btn-bg2.png") no-repeat;
            background-size: 80px 35px;
        }
    } 

    这里通过改变statistics的值,判断是否与li标签的id相等而去动态添加active类,浏览器中打印出来 statistics的值有改变,但是页面却不渲染,active并没有加上,不知道什么原因

    3
    打赏
    收藏
    点击回答
    您的回答被采纳后将获得:提问者悬赏的 11 元积分
        全部回答
    • 0
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部