iview/examples/routers/modal.vue

56 lines
1.7 KiB
Vue
Raw Normal View History

2017-03-09 18:31:47 +08:00
<template>
<div>
2017-07-19 18:18:43 +08:00
<i-button @click="modal=true">show modal</i-button>
<Modal v-model="modal" @on-ok="resetForm" @on-cancel="resetForm" title="表单">
2017-07-18 10:24:21 +08:00
<div>
2017-07-19 18:18:43 +08:00
<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>
2017-07-18 10:24:21 +08:00
</div>
2017-06-01 19:00:37 +08:00
</Modal>
2017-03-09 18:31:47 +08:00
</div>
</template>
<script>
export default {
2017-06-01 19:00:37 +08:00
data () {
return {
2017-07-19 18:18:43 +08:00
modal: false,
loading: false,
options: [],
cityList: [
{
value: "beijing",
label: "北京市"
},
{
value: "shanghai",
label: "上海市"
}
]
2017-06-01 19:00:37 +08:00
}
},
2017-03-09 18:31:47 +08:00
methods: {
2017-06-01 19:00:37 +08:00
ok () {
this.$Message.info('点击了确定');
},
cancel () {
this.$Message.info('点击了取消');
},
2017-07-19 18:18:43 +08:00
remoteMethod(query) {
this.loading = true;
setTimeout(() => {
this.loading = false;
this.options = this.cityList;
}, 200);
},
resetForm() {
//加个计时器,就能解决这个定位问题了
// setTimeout(()=> {
this.$refs["formSelect"].clearSingleSelect();
this.options = [];
// }, 300)
2017-03-09 18:31:47 +08:00
}
}
}
</script>