Commit cc419499906a2321410e8a446ae690688ccd96a2
1 parent
d270488b
fixed #525
Showing
2 changed files
with
62 additions
and
15 deletions
Show diff stats
examples/routers/form.vue
... | ... | @@ -266,11 +266,11 @@ |
266 | 266 | <template> |
267 | 267 | <div> |
268 | 268 | <Form ref="DateForm" :model="form" :rules="rules" :label-width="80" style="width: 400px;"> |
269 | - <Form-item label="选择日期" prop="date"> | |
270 | - <Date-picker v-model="form.date" type="datetime"></Date-picker> | |
269 | + <Form-item label="选择日期" prop="value1"> | |
270 | + <Cascader :data="form.data" v-model="form.value1"></Cascader> | |
271 | 271 | </Form-item> |
272 | 272 | <Form-item> |
273 | - <Button type="primary" @click.native="handleClick">确定</Button> | |
273 | + <Button type="primary" @click="handleClick">确定</Button> | |
274 | 274 | </Form-item> |
275 | 275 | </Form> |
276 | 276 | </div> |
... | ... | @@ -280,12 +280,62 @@ |
280 | 280 | data () { |
281 | 281 | return { |
282 | 282 | form: { |
283 | - date: '' | |
283 | + value1: [], | |
284 | + data: [{ | |
285 | + value: 'beijing', | |
286 | + label: '北京', | |
287 | + children: [ | |
288 | + { | |
289 | + value: 'gugong', | |
290 | + label: '故宫' | |
291 | + }, | |
292 | + { | |
293 | + value: 'tiantan', | |
294 | + label: '天坛' | |
295 | + }, | |
296 | + { | |
297 | + value: 'wangfujing', | |
298 | + label: '王府井' | |
299 | + } | |
300 | + ] | |
301 | + }, { | |
302 | + value: 'jiangsu', | |
303 | + label: '江苏', | |
304 | + children: [ | |
305 | + { | |
306 | + value: 'nanjing', | |
307 | + label: '南京', | |
308 | + children: [ | |
309 | + { | |
310 | + value: 'fuzimiao', | |
311 | + label: '夫子庙', | |
312 | + } | |
313 | + ] | |
314 | + }, | |
315 | + { | |
316 | + value: 'suzhou', | |
317 | + label: '苏州', | |
318 | + children: [ | |
319 | + { | |
320 | + value: 'zhuozhengyuan', | |
321 | + label: '拙政园', | |
322 | + }, | |
323 | + { | |
324 | + value: 'shizilin', | |
325 | + label: '狮子林', | |
326 | + } | |
327 | + ] | |
328 | + } | |
329 | + ], | |
330 | + }] | |
284 | 331 | }, |
285 | 332 | rules: { |
286 | - date: [ | |
287 | - { required: true, type: 'date', message: '不能为空', trigger: 'change' }, | |
288 | - { type: 'date', message: '日期格式不正确', trigger: 'change'} | |
333 | + value1: [ | |
334 | + { | |
335 | + required: true, | |
336 | + type: 'array', | |
337 | + message: '没有填写' | |
338 | + } | |
289 | 339 | ] |
290 | 340 | } |
291 | 341 | } |
... | ... | @@ -294,11 +344,6 @@ |
294 | 344 | handleClick() { |
295 | 345 | this.$refs.DateForm.validate(); |
296 | 346 | } |
297 | - }, | |
298 | - watch: { | |
299 | - 'form.date' (val) { | |
300 | - console.log(val); | |
301 | - } | |
302 | 347 | } |
303 | 348 | } |
304 | 349 | </script> |
305 | 350 | \ No newline at end of file | ... | ... |
src/components/cascader/cascader.vue
... | ... | @@ -162,9 +162,11 @@ |
162 | 162 | emitValue (val, oldVal) { |
163 | 163 | if (JSON.stringify(val) !== oldVal) { |
164 | 164 | this.$emit('on-change', this.currentValue, JSON.parse(JSON.stringify(this.selected))); |
165 | - this.dispatch('FormItem', 'on-form-change', { | |
166 | - value: this.currentValue, | |
167 | - selected: JSON.parse(JSON.stringify(this.selected)) | |
165 | + this.$nextTick(() => { | |
166 | + this.dispatch('FormItem', 'on-form-change', { | |
167 | + value: this.currentValue, | |
168 | + selected: JSON.parse(JSON.stringify(this.selected)) | |
169 | + }); | |
168 | 170 | }); |
169 | 171 | } |
170 | 172 | } | ... | ... |