当前位置:   article > 正文

element源码学习笔记_elementui 源码学习

elementui 源码学习

element源码学习笔记
(1)方法简写

 if (!layout) {
      return null
    }
    // 如果if大括号里只有单行,可以去除大括号
    if (!layout) return null;
    // else只有单行的2时候也可以去除大括号
const a = 7; if (a > 9) console.log(1); else console.log(2); 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

(2) 向数组开头添加新项,unshift()

template.children.unshift(rightWrapper);
  • 1

(3)判断是否是数组Array.isArray(newVal)

if (Array.isArray(newVal)) {
              this.$parent.internalPageSize = newVal.indexOf(this.$parent.pageSize) > -1
                ? this.$parent.pageSize
                : this.pageSizes[0];
            }
  • 1
  • 2
  • 3
  • 4
  • 5

(4)取父组件和子组的data,props ,方法,this.$parent

(5)动态样式:
:class=“[‘el-dialog’, { ‘is-fullscreen’: fullscreen, ‘el-dialog–center’: center }, customClass]”
解析: 该div始终有el-dialog,customClass,当fullscreen和center为true时,is-fullscreen,el-dialog–center存在

 <div
        role="dialog"
        :key="key"
        aria-modal="true"
        :aria-label="title || 'dialog'"
        :class="['el-dialog', { 'is-fullscreen': fullscreen, 'el-dialog--center': center }, customClass]"
        ref="dialog"
        :style="style">
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

(6)

this.$el.addEventListener('scroll', this.updatePopper), this.$el.removeEventListener('scroll', this.updatePopper);
  • 1

知识点1: $el :是 用于获取组件内 DOM(包括子组件,当前.vue组件,以及父组件)
知识点2:addEventListener:添加事件监听,removeEventListener:移除事件监听

(7)v-clickoutside=“close” 点击元素之外,触发事件
参考: 优秀博主具体讲解

(8)v-bind=“[$props, $attrs]”, 组件传值
参考:

优秀博主讲解

(9)inject

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/578408
推荐阅读
相关标签
  

闽ICP备14008679号