• element-ui button源码


    button/index.js
    import ElButton from './src/button';
    
    /* istanbul ignore next */
    ElButton.install = function(Vue) {
    Vue.component(ElButton.name, ElButton);
    };
    
    export default ElButton;
    

    src/button.vue

    <template>
      <button
        class="el-button"
        @click="handleClick"
        :disabled="buttonDisabled || loading"
        :autofocus="autofocus"
        :type="nativeType"
        :class="[
          type ? 'el-button--' + type : '',
          buttonSize ? 'el-button--' + buttonSize : '',
          {
            'is-disabled': buttonDisabled,
            'is-loading': loading,
            'is-plain': plain,
            'is-round': round,
            'is-circle': circle
          }
        ]"
      >
        <i class="el-icon-loading" v-if="loading"></i>
        <i :class="icon" v-if="icon && !loading"></i>
        <span v-if="$slots.default"><slot></slot></span>
      </button>
    </template>
    <script>
      export default {
        name: 'ElButton',
    
        inject: {
          elForm: {
            default: ''
          },
          elFormItem: {
            default: ''
          }
        },
    
        props: {
          type: {
            type: String,
            default: 'default'
          },
          size: String,
          icon: {
            type: String,
            default: ''
          },
          nativeType: {
            type: String,
            default: 'button'
          },
          loading: Boolean,
          disabled: Boolean,
          plain: Boolean,
          autofocus: Boolean,
          round: Boolean,
          circle: Boolean
        },
    
        computed: {
          _elFormItemSize() {
            return (this.elFormItem || {}).elFormItemSize;
          },
          buttonSize() {
            return this.size || this._elFormItemSize || (this.$ELEMENT || {}).size;
          },
          buttonDisabled() {
            return this.disabled || (this.elForm || {}).disabled;
          }
        },
    
        methods: {
          handleClick(evt) {
            this.$emit('click', evt);
          }
        }
      };
    </script>
    

      

  • 相关阅读:
    Hadoop 2.2.0单节点的伪分布集成环境搭建
    CentOS系统中出现错误--SSH:connect to host centos-py port 22: Connection refused
    JUnit 5和Selenium基础(三)
    JUnit 5和Selenium基础(二)
    JUnit 5和Selenium基础(一)
    如何对N个接口按比例压测
    性能测试中标记每个请求
    初学者的API测试技巧
    Web安全检查
    Groovy重载操作符
  • 原文地址:https://www.cnblogs.com/wsk1576025821/p/10912807.html
Copyright © 2020-2023  润新知