zoukankan      html  css  js  c++  java
  • vue :class 可以接收 字符串 数组 和 对象 对象里面的key值 根据true或false 显示不显示

    vue :class 可以接收 字符串 数组 和 对象 对象里面的key值 根据true或false 显示不显示

    https://cn.vuejs.org/v2/guide/class-and-style.html

    html部分 注意:class

    <component :is="tagName" :class="classes" :disabled="disabled" @click="handleClickLink" v-bind="tagProps">
            <Icon class="ivu-load-loop" type="ios-loading" v-if="loading"></Icon>
            <Icon :type="icon" :custom="customIcon" v-if="(icon || customIcon) && !loading"></Icon>
            <span v-if="showSlot" ref="slot"><slot></slot></span>
        </component>

    代码部分

    computed: {
                classes () {
                    return [
                        `${prefixCls}`,
                        `${prefixCls}-${this.type}`,
                        {
                            [`${prefixCls}-long`]: this.long,
                            [`${prefixCls}-${this.shape}`]: !!this.shape,
                            [`${prefixCls}-${this.size}`]: this.size !== 'default',
                            [`${prefixCls}-loading`]: this.loading != null && this.loading,
                            [`${prefixCls}-icon-only`]: !this.showSlot && (!!this.icon || !!this.customIcon || this.loading),
                            [`${prefixCls}-ghost`]: this.ghost
                        }
                    ];
                },

    第一个和第2个 肯定显示 后面对象里面就是true的显示 这个class

    false的就不显示这个class

  • 相关阅读:
    php详解和优化
    接口
    抽象类
    对象转型
    面向对象2
    Super关键字
    Object类介绍
    有效处理java异常的三个原则
    this关键字
    equals方法
  • 原文地址:https://www.cnblogs.com/pengchenggang/p/10620371.html
Copyright © 2011-2022 走看看