Files
xl-mobile/src/components/XDateTime.vue

42 lines
1.1 KiB
Vue
Raw Normal View History

2025-03-28 09:37:10 +08:00
<script setup>
import timeIcon from "../static/icons/time.png";
const modalValue = defineModel();
2025-04-21 15:19:28 +08:00
const {placeholder, fields} = defineProps({
2025-03-28 09:37:10 +08:00
placeholder: {
type: String,
default: "请选择时间",
2025-04-21 15:19:28 +08:00
},
fields: {
type: String,
default: 'day'
2025-03-28 09:37:10 +08:00
}
});
const success = ({detail: {value}}) => {
modalValue.value = value;
}
</script>
<template>
2025-04-21 15:19:28 +08:00
<picker mode="date" :class="[!$slots.default ? 'x-date-input' : '']" @change="success" :fields="fields">
<view v-if="!$slots.default" class="!flex items-center justify-center gap-[20rpx]">
<image class="!size-[24rpx]" :src="timeIcon"></image>
2025-03-28 09:37:10 +08:00
<text v-if="!modalValue" class="text-[#666]">{{ placeholder }}</text>
2025-04-21 15:19:28 +08:00
<text class="test-24r" v-else>{{ modalValue }}</text>
2025-03-28 09:37:10 +08:00
</view>
2025-04-21 15:19:28 +08:00
<slot v-else></slot>
2025-03-28 09:37:10 +08:00
</picker>
</template>
<style lang="scss" scoped>
.x-date-input {
background-color: #F2F3F5;
padding: 14rpx 0;
flex-grow: 1;
text-align: center;
border-radius: 4rpx;
position: relative;
}
</style>