Commit 7af00356a9d8d80c06366f639791982ee2757a68
1 parent
fed3e09d
update AutoComplete
Showing
4 changed files
with
8 additions
and
3 deletions
Show diff stats
examples/routers/auto-complete.vue
examples/routers/form.vue
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | <Form ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="80"> |
3 | 3 | <Form-item prop="name"> |
4 | 4 | <span slot="label"><Icon type="ionic"></Icon></span> |
5 | - <Input v-model="formValidate.name" placeholder="请输入姓名"></Input> | |
5 | + <AutoComplete v-model="formValidate.name" :data="['Li','Liang','Zhang']" placeholder="请输入姓名"></AutoComplete> | |
6 | 6 | </Form-item> |
7 | 7 | <Form-item label="邮箱" prop="mail"> |
8 | 8 | <Input v-model="formValidate.mail" placeholder="请输入邮箱"></Input> |
... | ... | @@ -56,6 +56,7 @@ |
56 | 56 | export default { |
57 | 57 | data () { |
58 | 58 | return { |
59 | + name: '', | |
59 | 60 | formValidate: { |
60 | 61 | name: '', |
61 | 62 | mail: '', |
... | ... | @@ -68,7 +69,7 @@ |
68 | 69 | }, |
69 | 70 | ruleValidate: { |
70 | 71 | name: [ |
71 | - { required: true, message: '姓名不能为空', trigger: 'blur' } | |
72 | + { required: true, message: '姓名不能为空', trigger: 'change' } | |
72 | 73 | ], |
73 | 74 | mail: [ |
74 | 75 | { required: true, message: '邮箱不能为空', trigger: 'blur' }, | ... | ... |
src/components/auto-complete/auto-complete.vue
... | ... | @@ -36,9 +36,11 @@ |
36 | 36 | import iOption from '../select/option.vue'; |
37 | 37 | import iInput from '../input/input.vue'; |
38 | 38 | import { oneOf } from '../../utils/assist'; |
39 | + import Emitter from '../../mixins/emitter'; | |
39 | 40 | |
40 | 41 | export default { |
41 | 42 | name: 'AutoComplete', |
43 | + mixins: [ Emitter ], | |
42 | 44 | components: { iSelect, iOption, iInput }, |
43 | 45 | props: { |
44 | 46 | value: { |
... | ... | @@ -103,6 +105,7 @@ |
103 | 105 | this.$refs.select.query = val; |
104 | 106 | this.$emit('input', val); |
105 | 107 | this.$emit('on-change', val); |
108 | + this.dispatch('FormItem', 'on-form-change', val); | |
106 | 109 | } |
107 | 110 | }, |
108 | 111 | methods: { | ... | ... |
src/components/select/select.vue