ant-design-vue/components/vc-select/demo/email.vue

49 lines
1023 B
Vue
Raw Normal View History

2018-02-11 18:04:31 +08:00
<script>
2019-01-12 11:33:27 +08:00
import Select, { Option } from '../index';
import '../assets/index.less';
2018-02-11 18:04:31 +08:00
export default {
2019-09-28 20:45:07 +08:00
data() {
2018-02-11 18:04:31 +08:00
return {
disabled: false,
options: [],
2019-01-12 11:33:27 +08:00
};
2018-02-11 18:04:31 +08:00
},
methods: {
2019-09-28 20:45:07 +08:00
onChange(value) {
2019-01-12 11:33:27 +08:00
console.log('onChange', value);
let options = [];
2018-02-11 18:04:31 +08:00
if (value) {
if (value.indexOf('@') >= 0) {
2019-01-12 11:33:27 +08:00
options = <Option key={value}>{value}</Option>;
2018-02-11 18:04:31 +08:00
} else {
2019-09-28 20:45:07 +08:00
options = ['gmail.com', 'yahoo.com', 'outlook.com'].map(domain => {
2019-01-12 11:33:27 +08:00
const email = `${value}@${domain}`;
return <Option key={email}>{email}</Option>;
});
2018-02-11 18:04:31 +08:00
}
}
2019-01-12 11:33:27 +08:00
this.options = options;
2018-02-11 18:04:31 +08:00
},
2019-09-28 20:45:07 +08:00
onSelect(v) {
2019-01-12 11:33:27 +08:00
console.log('onSelect', v);
2018-02-11 18:04:31 +08:00
},
},
2019-09-28 20:45:07 +08:00
render() {
return (
<Select
combobox
notFoundContent={false}
style="width: 200px"
onChange={this.onChange}
onSelect={this.onSelect}
placeholder="请输入账户名"
>
{this.options}
</Select>
);
2018-02-11 18:04:31 +08:00
},
2019-01-12 11:33:27 +08:00
};
2018-02-11 18:04:31 +08:00
</script>