Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

element cascader级联选择,回显不了数据

<el-cascader :options="options" v-model=“value” :show-all-levels="false"></el-cascader>  
<script> 
export default { 
    data() { 
        return { 
            options: [
            { 
                value: 'zhinan', 
                label: '指南', 
                children: [
                    { 
                        value: 'shejiyuanze', 
                        label: '设计原则', 
                        children: [
                            { 
                                value: 'yizhi', 
                                label: '一致' 
                            }, 
                            { 
                                value: 'fankui', 
                                label: '反馈' 
                            },
                        ]
                    }
                 ]
             }
         ]
      }
    }
}

后台返回的数据是

item = { 
          value: 'yizhi', 
          label: '一致' 
      }

怎么能把数据回显到 cascader中呢?直接把item赋值给value是不行的


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

没太完全理解您的疑问。

只要将后台返回的数据结构按照官网给出的格式进行解析即可。二级菜单放在children里。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...