This commit is contained in:
梁灏 2017-04-10 22:43:24 +08:00
parent 96a6cb6c2e
commit 65b41a2d6f
2 changed files with 28 additions and 129 deletions

View file

@ -1,141 +1,39 @@
<!--<template>-->
<!--<div>-->
<!--<Cascader :data="data" v-model="value1"></Cascader>-->
<!--{{ value1 }}-->
<!--<div @click="c">change</div>-->
<!--</div>-->
<!--</template>-->
<!--<script>-->
<!--export default {-->
<!--data () {-->
<!--return {-->
<!--value1: [],-->
<!--data: [{-->
<!--value: 'beijing',-->
<!--label: '北京',-->
<!--children: [-->
<!--{-->
<!--value: 'gugong',-->
<!--label: '故宫'-->
<!--},-->
<!--{-->
<!--value: 'tiantan',-->
<!--label: '天坛'-->
<!--},-->
<!--{-->
<!--value: 'wangfujing',-->
<!--label: '王府井'-->
<!--}-->
<!--]-->
<!--}, {-->
<!--value: 'jiangsu',-->
<!--label: '江苏',-->
<!--children: [-->
<!--{-->
<!--value: 'nanjing',-->
<!--label: '南京',-->
<!--children: [-->
<!--{-->
<!--value: 'fuzimiao',-->
<!--label: '夫子庙',-->
<!--}-->
<!--]-->
<!--},-->
<!--{-->
<!--value: 'suzhou',-->
<!--label: '苏州',-->
<!--children: [-->
<!--{-->
<!--value: 'zhuozhengyuan',-->
<!--label: '拙政园',-->
<!--},-->
<!--{-->
<!--value: 'shizilin',-->
<!--label: '狮子林',-->
<!--}-->
<!--]-->
<!--}-->
<!--],-->
<!--}]-->
<!--}-->
<!--},-->
<!--methods: {-->
<!--c () {-->
<!--this.value1 = ['jiangsu', 'suzhou', 'zhuozhengyuan']-->
<!--}-->
<!--}-->
<!--}-->
<!--</script>-->
<template> <template>
<div> <div>
<Cascader :data="data" v-model="value2"></Cascader> <Cascader :data="data2" v-model="v1" disabled clearable></Cascader>
{{ value2 }} <Cascader :data="data2" clearable></Cascader>
<Button @click="c">clear</Button>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
data () { data () {
return { return {
value2: ['beijing', 'gugong'], v1: ['zhejiang', 'hangzhou', 'xihu'],
data: [] data2: [{
} value: 'zhejiang',
}, label: '浙江',
methods: { children: [{
c () { value: 'hangzhou',
this.value2 = [] label: '杭州',
} children: [{
}, value: 'xihu',
mounted () { label: '西湖'
this.data = [{ }]
value: 'beijing', }]
label: '北京',
children: [
{
value: 'gugong',
label: '故宫'
},
{
value: 'tiantan',
label: '天坛'
},
{
value: 'wangfujing',
label: '王府井'
}
]
}, { }, {
value: 'jiangsu', value: 'jiangsu',
label: '江苏', label: '江苏',
children: [ disabled: true,
{ children: [{
value: 'nanjing', value: 'nanjing',
label: '南京', label: '南京',
children: [ children: [{
{ value: 'zhonghuamen',
value: 'fuzimiao', label: '中华门'
label: '夫子庙', }]
} }]
]
},
{
value: 'suzhou',
label: '苏州',
children: [
{
value: 'zhuozhengyuan',
label: '拙政园',
},
{
value: 'shizilin',
label: '狮子林',
}
]
}
],
}] }]
} }
} }
}
</script> </script>

View file

@ -112,7 +112,7 @@
]; ];
}, },
showCloseIcon () { showCloseIcon () {
return this.currentValue && this.currentValue.length && this.clearable; return this.currentValue && this.currentValue.length && this.clearable && !this.disabled;
}, },
displayRender () { displayRender () {
let label = []; let label = [];
@ -125,6 +125,7 @@
}, },
methods: { methods: {
clearSelect () { clearSelect () {
if (this.disabled) return false;
const oldVal = JSON.stringify(this.currentValue); const oldVal = JSON.stringify(this.currentValue);
this.currentValue = this.selected = this.tmpSelected = []; this.currentValue = this.selected = this.tmpSelected = [];
this.handleClose(); this.handleClose();