<template> <!-- 级联选择器 --> <el-cascader :props="defaultParams" :options="options" v-model="selectedOptions" :clearable="true" :style="{ width: ‘100%‘ }" ></el-cascader> </template> <script> export default { data() { return { options: [], selectedOptions: [], defaultParams: { label: ‘cat_name‘, value: ‘cat_id‘, children: ‘children‘, checkStrictly: true } } }, created() { this.addCate() }, methods: { async addCate() { const { data: res } = await this.$http.get(‘categories‘, { params: { type: 3 } }) this.options = res.data } } } </script> <style lang="less" scoped> </style>
原文:https://www.cnblogs.com/wangdong9395/p/11920960.html