vue树形下拉多选组件vue-treeselect基础使用

​官网使用方法:Vue-Treeselect | Vue-Treeselect 中文网    进阶版请查看:https://www.cnblogs.com/gyw1996/p/15923912.html

//vue页面

复制代码
 <el-form-item label="岗位">
  <treeselect
    :multiple="multiple"
    v-model="form.postIds"
    :options="postOptions"
    :show-count="true"
    placeholder="请选择岗位"
    :limit="6"
    :limitText="count => `及其它${count}项`"
  />
</el-form-item>
复制代码
//vue页面方法
复制代码
import { treeselect } from '@/api/system/dept'
import Treeselect from '@riophae/vue-treeselect'
export default{ components: { Treeselect }, data(){ return{ postOptions: [], form:{} }
}, created(){
post().then((response)
=> {//这是你从后台调数据的接口方法 this.postOptions = response.data //这里是后台拿到的整个下拉框数据 })
getUser(userId).then((response)
=> {//这里也是调用的后台接口
this.form = response.data //这是我自己页面要用的数据

//
this.form.postIds就是多选选中的数据
  this.form.postIds = response.postIds //这里是赋值,之前已经选中的数据
 })
},
}
复制代码

 

 

 

posted @   彳小闲鱼  阅读(2965)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示