欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

element-ui?實(shí)現(xiàn)輸入框下拉樹(shù)組件功能

 更新時(shí)間:2024年05月25日 11:04:58   作者:寶子卡粉  
這篇文章主要介紹了element-ui?實(shí)現(xiàn)輸入框下拉樹(shù)組件功能,使用element-ui的?el-input,el-tree,el-popover組件組合封裝,本文結(jié)合示例代碼給大家介紹的非常詳細(xì),感興趣的朋友跟隨小編一起看看吧

用element-ui的 el-input,el-tree,el-popover組件組合封裝

@import url("http://unpkg.com/element-ui@2.15.14/lib/theme-chalk/index.css");
<script src="http://unpkg.com/vue@2/dist/vue.js"></script>
<script src="http://unpkg.com/element-ui@2.15.14/lib/index.js"></script>
<div id="app">
  <el-popover
    placement="bottom"
    width="350"
    trigger="click">
    <el-tree
       style="width:300px"
       ref="tree"
       :data="options"
       :check-strictly="false"
        show-checkbox
        node-key="id"
        :default-expanded-keys="[]"
        :default-checked-keys="[]"
        :props="{
           children: 'children',
           label: 'name'
         }"
         @check-change="handleCheckChage"
         @node-click="handleNodeClick"
     >
    </el-tree>
        <el-input slot="reference" 
          style="width:380px"
         v-model="value.name" 
         placeholder="節(jié)點(diǎn)" 
         clearable 
         @clear="handleIptClear">
       </el-input>
  </el-popover>
</div>
var Main = {
    data() {
      return {
        options: [
          {id:'1', name: '1',
           children:[
             {id:'11', name: '11'},
             {id:'12', name: '12'}
           ]
          },
          {id:'2', name: '2'}
        ],
        value:{id:'', name: ''}
      }
    },
    methods: {
      // 清空輸入框內(nèi)容
        handleIptClear(){
            this.$refs.tree.setCheckedNodes([])
            this.value.id = ''
            this.value.name = ''
        },
        // checkbox被選中或取消選中
        handleCheckChage(arg1, arg2, arg3){
            const seltedNodes = this.$refs.tree.getCheckedNodes()
            const ids = seltedNodes.map(n => n.id)
            const names = seltedNodes.map(n => n.name)
            this.value.id = ids
            this.value.name = names
        },
        // 節(jié)點(diǎn)被點(diǎn)擊
        handleNodeClick(arg1, arg2, arg3){
            console.log('nodes:', arg1, arg2, arg3)
        },
    }
  };
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')

可以根據(jù)函數(shù)方法拿到里面的參數(shù),實(shí)現(xiàn)多選節(jié)點(diǎn)效果

到此這篇關(guān)于element-ui 實(shí)現(xiàn)輸入框下拉樹(shù)組件功能的文章就介紹到這了,更多相關(guān)element-ui 輸入框下拉樹(shù)組件內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論