ant-design-vue/components/vc-cascader/demo/animation.vue

81 lines
1.3 KiB
Vue
Raw Normal View History

2018-03-02 14:12:52 +00:00
<script>
/* eslint-disable no-console */
2019-01-12 03:33:27 +00:00
import '../assets/index.less';
import Cascader from '../index';
2018-03-02 14:12:52 +00:00
2019-09-28 12:45:07 +00:00
const addressOptions = [
{
label: '福建',
value: 'fj',
children: [
{
label: '福州',
value: 'fuzhou',
children: [
{
label: '马尾',
value: 'mawei',
},
],
},
{
label: '泉州',
value: 'quanzhou',
},
],
},
{
label: '浙江',
value: 'zj',
children: [
{
label: '杭州',
value: 'hangzhou',
children: [
{
label: '余杭',
value: 'yuhang',
},
],
},
],
},
{
label: '北京',
value: 'bj',
children: [
{
label: '朝阳区',
value: 'chaoyang',
},
{
label: '海淀区',
value: 'haidian',
},
],
},
];
2018-03-02 14:12:52 +00:00
export default {
2019-09-28 12:45:07 +00:00
data() {
2018-03-02 14:12:52 +00:00
return {
inputValue: '',
2019-01-12 03:33:27 +00:00
};
2018-03-02 14:12:52 +00:00
},
methods: {
2019-09-28 12:45:07 +00:00
onChange(value, selectedOptions) {
2019-01-12 03:33:27 +00:00
console.log(value, selectedOptions);
this.inputValue = selectedOptions.map(o => o.label).join(', ');
2018-03-02 14:12:52 +00:00
},
},
2019-09-28 12:45:07 +00:00
render() {
2018-03-02 14:12:52 +00:00
return (
2019-09-28 12:45:07 +00:00
<Cascader options={addressOptions} onChange={this.onChange} transitionName="slide-up">
<input value={this.inputValue} />
2018-03-02 14:12:52 +00:00
</Cascader>
2019-01-12 03:33:27 +00:00
);
2018-03-02 14:12:52 +00:00
},
2019-01-12 03:33:27 +00:00
};
2018-03-02 14:12:52 +00:00
</script>