elementui select组件下拉框底部增加自定义按钮

elementui select组件下拉框底部增加自定义按钮

elementui select组件下拉框底部增加自定义按钮_第1张图片

el-select组件的visible-change 事件(下拉框出现/隐藏时触发)



visibleChange(visible) {
      // 下拉框显示隐藏
      if (visible) {
        const ref = this.$refs.select
        let popper = ref.$refs.popper
        if (popper.$el) popper = popper.$el
        // 判断是否有添加按钮
        if (!Array.from(popper.children).some(v => v.className === 'btn-box')) {
          const el = document.createElement('div')
          el.className = 'btn-box'
          el.innerHTML = `
                            添加
                          `
          popper.appendChild(el)
          el.onclick = () => {
            // todo
          }
        }
      }
    },

你可能感兴趣的:(前端,elementui,前端,javascript)