更新日期选择器
This commit is contained in:
@@ -1,26 +1,38 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, ref } from "vue";
|
import { onMounted, ref, watch } from "vue";
|
||||||
import Litepicker from "litepicker";
|
import Litepicker from "litepicker";
|
||||||
|
import { useI18n } from "vue-i18n";
|
||||||
|
const { t, locale } = useI18n();
|
||||||
|
|
||||||
const datepicker_inline = ref(null);
|
const datepicker = ref(null);
|
||||||
|
var picker = null
|
||||||
|
|
||||||
|
watch(locale, () => {
|
||||||
|
picker?.setOptions({ lang: locale.value });
|
||||||
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
|
|
||||||
new Litepicker({
|
picker = new Litepicker({
|
||||||
element: datepicker_inline.value,
|
element: datepicker.value,
|
||||||
lang: 'zh-cn',
|
lang: locale.value,
|
||||||
firstDay: 0,
|
firstDay: 0,
|
||||||
buttonText: {
|
format: "YYYY-MM-DD", // 日期格式
|
||||||
previousMonth: `<!-- Download SVG icon from http://tabler-icons.io/i/chevron-left -->
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M15 6l-6 6l6 6" /></svg>`,
|
|
||||||
nextMonth: `<!-- Download SVG icon from http://tabler-icons.io/i/chevron-right -->
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M9 6l6 6l-6 6" /></svg>`,
|
|
||||||
},
|
|
||||||
inlineMode: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
// @formatter:on
|
dropdowns: {
|
||||||
|
minYear: 1900, // 最小可选年份
|
||||||
|
maxYear: new Date().getFullYear() + 1, // 最大为当前年份
|
||||||
|
months: true, // 显示月份下拉
|
||||||
|
years: true, // 显示年份下拉
|
||||||
|
},
|
||||||
|
//inlineMode: true,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
datepicker,
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -54,13 +66,8 @@ onMounted(() => {
|
|||||||
<input
|
<input
|
||||||
class="form-control"
|
class="form-control"
|
||||||
placeholder="Select a date"
|
placeholder="Select a date"
|
||||||
id="datepicker-icon-prepend"
|
ref="datepicker"
|
||||||
value="2020-06-20"
|
value=""
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
<label class="form-label">Inline datepicker</label>
|
|
||||||
<div class="datepicker-inline" ref="datepicker_inline"></div>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,8 +1,17 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
|
import { onMounted, watch, ref } from 'vue'
|
||||||
import settingNavigation from "@/components/settingNavigation.vue";
|
import settingNavigation from "@/components/settingNavigation.vue";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import datePicker from "@/components/datePicker.vue";
|
import datePicker from "@/components/datePicker.vue";
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
|
const datapicker = ref();
|
||||||
|
|
||||||
|
function updataInfo() {
|
||||||
|
console.log("保存用户信息");
|
||||||
|
console.log("生日:", datapicker.value.datepicker.value);
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -49,12 +58,11 @@ const { t } = useI18n();
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-md">
|
<div class="col-md">
|
||||||
<div class="form-label">{{ t("settings.birthday") }}</div>
|
<div class="form-label">{{ t("settings.birthday") }}</div>
|
||||||
<input type="text" class="form-control" />
|
<datePicker ref="datapicker"/>
|
||||||
<datePicker />
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<button class="btn">{{ t("settings.save_changes") }}</button>
|
<button class="btn" @click="updataInfo">{{ t("settings.save_changes") }}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<h3 class="card-title mt-4">{{ t("settings.email") }}</h3>
|
<h3 class="card-title mt-4">{{ t("settings.email") }}</h3>
|
||||||
|
|||||||
Reference in New Issue
Block a user