原文:https://www.jianshu.com/p/b690d7fe6ec0數組
注意兩點就好了ui
<el-form-item label="AP名稱"> <el-cascader v-model="ruleForm.ap" :options="apOptions" change-on-select> </el-cascader> </el-form-item>
apOptions:[ { value:'', label: '所有' } ,{ value: 'zhinan', label: '指南', children: [ { value: 'shejiyuanze', label: '設計原則', children: [{ value: 'yizhi', label: '一致' }, { value: 'fankui', label: '反饋' }, { value: 'xiaolv', label: '效率' }, { value: 'kekong', label: '可控' }] }, { value: 'daohang', label: '導航', children: [{ value: 'cexiangdaohang', label: '側向導航' }, { value: 'dingbudaohang', label: '頂部導航' }] }] } ]
第一點v-model="ruleForm.ap"綁定得是數組this
第二點設置默認值得時候設置得是label對應得value
如上面得數據我想設置默認值是所有 就要以下設置spa
this.ruleForm.ap = ['']
由於label對應得value是''設計
再舉個例子想在頁面默認顯示 指南/設計原則/一致
this.ruleForm.ap = ['zhinan','shejiyuanze','yizhi']