样式冲突(使用了elementui)
场景:在el-form标签中,如果使用了标签,并且父标签不是的话,就会出现无法点击的问题。(没有严格按elementui的标签嵌套)
<el-row>
<el-col :span="24" v-if="form.parentId !== 0">
<el-form-item label="上级字典" prop="parentId">
<treeselect v-model="parentId" :options="dictOptions" />
</el-form-item>
</el-col>
</el-row>
<el-col :span="24" >
<el-form-item label="上级字典" prop="parentId">
<treeselect v-model="parentId" :options="dictOptions" />
</el-form-item>
</el-col>
其他场景下,应该也是样式冲突的问题。
@riophae/vue-treeselect":"^0.0.37
这是vue官方的中文文档可以参考 https://www.vue-treeselect.cn/#node
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
components: {
Loadding,
Treeselect,
},
<div class="search_row_label">单位管理范围:</div>
<div class="search_row_content">
<treeselect
noResultsText="暂无结果"
v-model="dwgxfw"
clearValueText="删除" //“×”按钮的标题
:searchable="false" //是否启用搜索功能
:options="szxzList" //选项数据
:load-options="loadOptions" //用于动态加载选项
placeholder="请选择"
@select="changeSelect" //选择一个选项后发出用于选择
@input="inputChange" //输入框值更改后发出触发
>
</treeselect>
首先需要先获取到父节点的值
getParentLocalityName(){
this.getRequest(this.Jurisdiction,"s_kj/s_kj_02/s_kj_02_01/loadDiscritctTreeRootNode","").then(res=>{
// this.Loadding = false;
//这里先判断状态
if(res.data.state==1){
let resData = res.data.data
let objData = {} //定义一个空对象
objData.id = resData.localitycode;
objData.label = resData.localityname;
objData.name = resData.localitydesc;
objData.children = null;
this.szxzList.push(objData) //在这里将获取到的数据代入
console.log(this.szxzList)
}else{
this.Loadings = false;
this.$Message.error(res.data.msg);
}
}).catch(error=>{
this.Loadings = false;
})
loadOptions({action,parentNode,callback}){
//这里有三个参数
action 获取到的值
parentNode 加载子选项时显示
callback 接受error参数的函数
console.log(parentNode)
let params={
parentLocCode: parentNode.id
}
this.getRequest(this.Jurisdiction,"s_kj/s_kj_02/s_kj_02_01/loadDiscrictTreeNode",urlPath(params)).then(res=>{
if(res.data.state==1){
if(res.data.data.length>0){
let resData =res.data.data
let arr = [] //定义空数组
resData.forEach(item=>{
let objData={}
objData.id = item.localitycode;
objData.label = item.localityname;
objData.name = item.localitydesc;
console.log(item.localitylevel)
if (item.localitylevel <=item.localitylevel+1) { //这里选择需要获取几个子节点进行判断
objData.children = null
objData.loading=false;
}
arr.push(objData) //将获取的数据代入
})
parentNode.children = arr;
callback();
}
}
})
},
changeSelect(n,i){
console.log(n)
if (n.label == "长江流域") {
this.dwgxfw = "";
} else {
console.log(222)
this.dwgxfw = n.label;
this.dwglcode = n.id
}
},
inputChange(n, i) {
if (n == undefined) {
this.dwgxfw = "";
}
},
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
长按识别二维码并关注微信
更方便到期提醒、手机管理