element-ui组件el-tree实现单选

it2022-05-05  160

转自:http://www.pianshen.com/article/3665136583/

<template> <div> <el-tree :props="defaultProps" :load="loadNode" lazy ref="tree" show-checkbox node-key="comcode" // 看项目和数据而定,有的为id :check-strictly="true" @check-change="handleClick" @node-click="nodeClick" > </el-tree> </div> </template> <script> methods:{ handleClick(data, checked, node){ if(checked == true){ this.checkedId = data.comcode; this.$refs.tree.setCheckedNodes([data]); } }, nodeClick(data,checked,node){ this.checkedId = data.comcode this.$refs.tree.setCheckedNodes([data]); } } </script>

最新回复(0)