VUE控件 VueTreeselect 參數options的數據轉換


VueTreeselect 控件

            <Treeselect
                    :options="options"
                    :normalizer="normalizer"
                    placeholder="請選擇..."                    
                    v-model="addEventForm.parentId"/>

options的值是個樹形結構的數組,normalizer屬性,是用於轉換options的值的,把options的值,轉換為符合vue-treeselect要求的數據格式。

//后台返回的數據如果和VueTreeselect要求的數據結構不同,需要進行轉換
normalizer(node){
	//去掉children=[]的children屬性
	if(node.children && !node.children.length){
		delete node.children;
	}
	return {
		id: node.id,
		label:node.name,
		children:node.children
	}
}

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM