ant-design-vue/components/time-picker/demo/value.md

44 lines
772 B
Markdown
Raw Normal View History

2018-03-08 15:02:04 +00:00
<cn>
#### 受控组件
value 和 onChange 需要配合使用。也可以直接使用v-model。
</cn>
<us>
#### Under Control
`value` and `@change` should be used together or use v-model.
</us>
2019-10-09 10:32:23 +00:00
```tpl
2018-03-08 15:02:04 +00:00
<template>
<div>
<p>use value and @change</p>
<a-time-picker @change="onChange" :value="value" />
2019-09-28 12:45:07 +00:00
<br />
<br />
2018-03-08 15:02:04 +00:00
<p>v-model</p>
<a-time-picker v-model="value" />
2019-09-28 12:45:07 +00:00
<br />
<br />
2018-03-08 15:02:04 +00:00
<p>Do not change</p>
<a-time-picker :value="value2" />
</div>
</template>
<script>
2019-09-28 12:45:07 +00:00
import moment from 'moment';
export default {
data() {
return {
value: null,
value2: moment(),
};
},
methods: {
onChange(time) {
console.log(time);
this.value = time;
},
},
};
2018-03-08 15:02:04 +00:00
</script>
```