fix: update types

This commit is contained in:
Qiuxia Fan 2022-02-15 15:31:51 +08:00
parent 895bed9ab2
commit 832521af9d
2 changed files with 10 additions and 9 deletions

View File

@ -118,9 +118,9 @@ limitations under the License. -->
v-for="(i, j) in local.months"
@click="
is($event) &&
((state.showMonths = m === 'M'),
((state.showMonths = state.m === 'M'),
(state.month = j),
m === 'M' && ok('m'))
state.m === 'M' && ok('m'))
"
:class="[
status(
@ -142,7 +142,7 @@ limitations under the License. -->
v-for="(i, j) in years"
@click="
is($event) &&
((state.showYears = m === 'Y'),
((state.showYears = state.m === 'Y'),
(state.year = i),
state.m === 'Y' && ok('y'))
"
@ -278,6 +278,7 @@ limitations under the License. -->
<script lang="ts" setup>
import { computed, onMounted, watch, reactive } from "vue";
import type { PropType } from "vue";
import { useI18n } from "vue-i18n";
/*global defineProps, defineEmits */
const emit = defineEmits(["input", "setDates", "ok"]);
@ -286,7 +287,7 @@ const props = defineProps({
value: { type: Date },
left: { type: Boolean, default: false },
right: { type: Boolean, default: false },
dates: { default: [] },
dates: { type: Array as PropType<number[] | string[]>, default: () => [] },
disabledDate: { type: Function, default: () => false },
format: {
type: String,
@ -353,10 +354,10 @@ const parse = (num: number): number => {
return Math.floor(num / 1000);
};
const start = computed(() => {
return parse(props.dates[0]);
return parse(Number(props.dates[0]));
});
const end = computed(() => {
return parse(props.dates[1]);
return parse(Number(props.dates[1]));
});
const ys = computed(() => {
return Math.floor(state.year / 10) * 10;
@ -550,7 +551,7 @@ const ok = (info: any) => {
emit("setDates", _time);
}
emit("input", _time);
ok(info === "h");
emit("ok", info === "h");
};
onMounted(() => {
const is = (c: string) => props.format.indexOf(c) !== -1;

View File

@ -149,7 +149,7 @@ import DateCalendar from "./DateCalendar.vue";
const datepicker = ref(null);
const { t } = useI18n();
const show = ref<boolean>(false);
const dates = ref<Date[]>([]);
const dates = ref<Date | string[] | any>([]);
const props = defineProps({
position: { type: String, default: "bottom" },
name: [String],
@ -244,7 +244,7 @@ const range = computed(() => {
const text = computed(() => {
const val = props.value;
const txt = dates.value
.map((date) => tf(date))
.map((date: Date) => tf(date))
.join(` ${props.rangeSeparator} `);
if (Array.isArray(val)) {
return val.length > 1 ? txt : "";