Skip to content

Commit 40ec099

Browse files
committed
fix: calendar popup v-model attr
1 parent a709dbb commit 40ec099

File tree

4 files changed

+14
-30
lines changed

4 files changed

+14
-30
lines changed

src/packages/calendar/demo.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
>
1111
</nut-cell>
1212
<nut-calendar
13-
:visible="isVisible"
13+
v-model:visible="isVisible"
1414
:default-value="date"
1515
@close="closeSwitch('isVisible')"
1616
@choose="setChooseValue"
@@ -29,7 +29,7 @@
2929
>
3030
</nut-cell>
3131
<nut-calendar
32-
:visible="isVisible1"
32+
v-model:visible="isVisible1"
3333
:default-value="date1"
3434
type="range"
3535
:start-date="`2019-12-22`"
@@ -50,7 +50,7 @@
5050
>
5151
</nut-cell>
5252
<nut-calendar
53-
:visible="isVisible3"
53+
v-model:visible="isVisible3"
5454
@close="closeSwitch('isVisible3')"
5555
@choose="setChooseValue3"
5656
:default-value="date3"
@@ -79,7 +79,6 @@ import { reactive, toRefs } from 'vue';
7979
import { createComponent } from '@/utils/create';
8080
8181
const { createDemo } = createComponent('calendar');
82-
import Utils from '@/utils/date';
8382
8483
interface TestCalendarState {
8584
isVisible: boolean;

src/packages/calendar/doc.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ app.use(Calendar);
2727
>
2828
</nut-cell>
2929
<nut-calendar
30-
:visible="isVisible"
30+
v-model:visible="isVisible"
3131
:default-value="date"
3232
@close="closeSwitch('isVisible')"
3333
@choose="setChooseValue"
@@ -74,7 +74,7 @@ setup() {
7474
>
7575
</nut-cell>
7676
<nut-calendar
77-
:visible="isVisible"
77+
v-model:visible="isVisible"
7878
:default-value="date"
7979
type="range"
8080
:start-date="`2019-12-22`"
@@ -120,7 +120,7 @@ setup() {
120120
>
121121
</nut-cell>
122122
<nut-calendar
123-
:visible="isVisible"
123+
v-model:visible="isVisible"
124124
@close="closeSwitch('isVisible')"
125125
@choose="setChooseValue"
126126
:start-date="null"

src/packages/calendar/index.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
position: relative;
33
display: flex;
44
flex: 1;
5-
height: 100%;
5+
height: 518px;
66
padding-top: 132px;
77
padding-bottom: 78px;
88
color: $calendar-base-color;

src/packages/calendar/index.vue

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<nut-popup
33
v-if="poppable"
4-
v-model:visible="childIsVisible"
4+
:visible="visible"
55
position="bottom"
66
round
77
:closeable="true"
@@ -39,7 +39,7 @@
3939
</nut-calendar-item>
4040
</template>
4141
<script lang="ts">
42-
import { PropType, reactive, ref, watch, toRefs } from 'vue';
42+
import { PropType, ref } from 'vue';
4343
import { createComponent } from '@/utils/create';
4444
const { create } = createComponent('calendar');
4545
import Popup from '@/packages/popup/index.vue';
@@ -62,7 +62,8 @@ export default create({
6262
default: true
6363
},
6464
visible: {
65-
type: Boolean
65+
type: Boolean,
66+
default: false
6667
},
6768
title: {
6869
type: String,
@@ -85,19 +86,14 @@ export default create({
8586
// element refs
8687
const calendarRef = ref<null | HTMLElement>(null);
8788
88-
// state
89-
const state = reactive({
90-
childIsVisible: false
91-
});
92-
9389
// methods
9490
const update = () => {
95-
state.childIsVisible = false;
91+
emit('update:visible', false);
9692
};
9793
9894
const close = () => {
99-
emit('update:visible', false);
10095
emit('close');
96+
emit('update:visible', false);
10197
};
10298
10399
const choose = (param: string) => {
@@ -109,23 +105,12 @@ export default create({
109105
close();
110106
};
111107
112-
watch(
113-
() => props.visible,
114-
val => {
115-
if (val) {
116-
state.childIsVisible = true;
117-
}
118-
}
119-
);
120-
121108
return {
122109
closePopup,
123110
update,
124111
close,
125112
choose,
126-
calendarRef,
127-
...toRefs(state),
128-
...toRefs(props)
113+
calendarRef
129114
};
130115
}
131116
});

0 commit comments

Comments
 (0)