在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/HTML/ elementUI中tree組件節(jié)點(diǎn)過(guò)濾功能用在循環(huán)中報(bào)錯(cuò)

elementUI中tree組件節(jié)點(diǎn)過(guò)濾功能用在循環(huán)中報(bào)錯(cuò)

用tree組件時(shí)使用了節(jié)點(diǎn)過(guò)濾,整個(gè)組件用在循環(huán)中報(bào)錯(cuò)
<li v-for="item in 3">

    <el-input placeholder="輸入關(guān)鍵字進(jìn)行過(guò)濾" v-model="filterText" @input="textCheckNode(filterText)"></el-input>
    <el-tree
        ref="tree"
        class="filter-tree"
        :props="defaultProps"
        :data="data2"
        default-expand-all
        show-checkbox
        :filter-node-method="filterNode">
    </el-tree>
</li>

上述input框因?yàn)閏hange事件不生效百度input才生效
下面為改變輸入框時(shí)的方法
textCheckNode(value){
     self.$refs.tree.filter(value)
 },

在調(diào)用時(shí)一輸入值就報(bào)改值is not a function

clipboard.png

另外如果我把for循環(huán)去掉就不會(huì)有問(wèn)題,但我是必須要循環(huán)的,請(qǐng)問(wèn)各位大佬有遇到過(guò)或者有解決辦法嗎?

回答
編輯回答
空痕

filter過(guò)濾器里面寫(xiě)方法啊,過(guò)濾條件。
看看這樣能不能解決你的需求
比方說(shuō)你獲取的完整的tree的數(shù)據(jù)為data2
你的tree的data數(shù)據(jù)綁定就使用::data="currentTreeData"

computed: {
    currentTreeData: function () {
        return data2.filter((item) => {
            return item === this.filterText;
        });
    }
}
2017年10月11日 02:44
編輯回答
玄鳥(niǎo)

你的ref不應(yīng)該相同,或者指定ref $refs.tree[0]

2017年12月26日 23:54