modal.vue
1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<template>
<div>
<i-button @click="modal=true">show modal</i-button>
<Modal v-model="modal" @on-ok="resetForm" @on-cancel="resetForm" title="表单">
<div>
<i-select ref="formSelect" filterable remote clearable :remote-method="remoteMethod" :loading="loading">
<i-option v-for="option in options" :value="option.value" :key="option.value">{{option.label}}</i-option>
</i-select>
</div>
</Modal>
</div>
</template>
<script>
export default {
data () {
return {
modal: false,
loading: false,
options: [],
cityList: [
{
value: "beijing",
label: "北京市"
},
{
value: "shanghai",
label: "上海市"
}
]
}
},
methods: {
ok () {
this.$Message.info('点击了确定');
},
cancel () {
this.$Message.info('点击了取消');
},
remoteMethod(query) {
this.loading = true;
setTimeout(() => {
this.loading = false;
this.options = this.cityList;
}, 200);
},
resetForm() {
//加个计时器,就能解决这个定位问题了
// setTimeout(()=> {
this.$refs["formSelect"].clearSingleSelect();
this.options = [];
// }, 300)
}
}
}
</script>