美文网首页
vue element Cascader 级联选择器

vue element Cascader 级联选择器

作者: 逸笛 | 来源:发表于2021-05-20 14:05 被阅读0次
图片.png

数据结构:


图片.png
    <el-cascader
              v-else
              :options="options"
              :props="optionProps"
              v-model="classData"
              @change="classChange"
              clearable
            ></el-cascader>
data () {
    return {
      // 规定联级菜单格式
      optionProps: {
        value: 'id',
        label: 'name',
        children: 'child'
      },
      optionsData: [],
      options: [], // 菜单目录
      classData: [], // 选中的菜单分类
    }

  created () {

      this.getClassData()

  },

接口获取菜单数据

    getClassData () {
      this.$api.post('/statistics/getqualitytab', {}, (res) => {
        if (res.status) {
          this.optionsData = res.data
        } else {
          this.$notify.warning({
            title: '提示',
            message: res.msg
          })
        }
      })
    },
  // 选择投稿分类
    classChange (value) {
      this.classData = value
    },

相关文章

网友评论

      本文标题:vue element Cascader 级联选择器

      本文链接:https://www.haomeiwen.com/subject/qyovjltx.html