12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <template>
- <div class="wrap">
- <DatePicker
- class="date-picker"
- :value="moment(value, 'YYYY-MM-DD')"
- @focus="onFocus"
- @change="onChange"
- @blur="onBlur"
- />
- <span>{{ reactData.tip }}</span>
- </div>
- </template>
- <script lang="ts">
- import { defineComponent, reactive, toRefs } from 'vue';
- import { DatePicker } from 'ant-design-vue';
- import moment from 'moment';
- const props = {
- value: { type: String, default: '' },
- tip: { type: String, default: '' },
- };
- export default defineComponent({
- components: { DatePicker },
- props,
- emits: ['change'],
- setup(props, { emit }) {
- const reactData = reactive({
- tip: '',
- });
- function onFocus() {
- reactData.tip = props.tip;
- }
- function onBlur() {
- reactData.tip = '';
- }
- function onChange(val) {
- emit('change', val);
- }
- return {
- onFocus,
- onBlur,
- onChange,
- reactData,
- moment,
- ...toRefs(props),
- };
- },
- });
- </script>
- <style scoped>
- .wrap {
- display: flex;
- }
- .date-picker {
- width: 55%;
- margin-right: 10px;
- }
- span {
- font-size: 13px;
- line-height: 250%;
- color: gray;
- }
- </style>
|