美文网首页
用变量同时控制div的class和数据

用变量同时控制div的class和数据

作者: kayleeWei | 来源:发表于2018-07-27 15:04 被阅读0次
<div @click="dropDownMenu">
    <i
        :class="{
            'el-icon-arrow-down': !showMore,
            'el-icon-arrow-up': showMore
        }">
    </i>
</div>

....
// script
data () {
        return {
          ...
           showMore: false
        }
 },
computed: {
    showTag () {
        if (this.showMore) {
            return this.data
        } else {
            return this.data.slice(0, 10)
        }
    }
}

....
dropDownMenu() {
    this.showMore = !this.showMore
}

相关文章

网友评论

      本文标题:用变量同时控制div的class和数据

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