picker-view日期组件vue3代码
时间: 2023-04-10 13:01:41 浏览: 194
我可以回答这个问题。在Vue3中使用picker-view日期组件的代码如下:
<template>
<picker-view :value="value" @change="onChange">
<picker-view-column>
<template v-for="year in years">
<view>{{ year }}</view>
</template>
</picker-view-column>
<picker-view-column>
<template v-for="month in months">
<view>{{ month }}</view>
</template>
</picker-view-column>
<picker-view-column>
<template v-for="day in days">
<view>{{ day }}</view>
</template>
</picker-view-column>
</picker-view>
</template>
<script>
export default {
data() {
return {
value: [0, 0, 0], // 初始值
years: [2021, 2022, 2023], // 年份
months: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], // 月份
days: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31], // 天数
};
},
methods: {
onChange(e) {
this.value = e.detail.value;
},
},
};
</script>
阅读全文