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

47 lines
999 B
Vue
Raw Normal View History

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