UNPKG

cione-comp-lib

Version:

`$ yarn add cione-comp-lib` 或者 `$ npm i cione-comp-lib -S`

102 lines (101 loc) 2.67 kB
import hooks from "../../node_modules/moment/dist/moment.mjs"; import { defineComponent, ref, onMounted, computed, toRefs, openBlock, createElementBlock, normalizeStyle, toDisplayString } from "vue"; import "../../node_modules/moment/dist/locale/zh-cn.mjs"; import "./index.vue_vue_type_style_index_0_scoped_true_lang.mjs"; import _export_sfc from "../../_virtual/plugin-vue_export-helper.mjs"; const _sfc_main = defineComponent({ name: "CoTimeDate", props: { fontSize: { type: [Number, String], default: 25 }, fontWeight: { type: String, default: "400" }, fontFamily: { type: String, default: "\u5FAE\u8F6F\u96C5\u9ED1" }, letterSpacing: { type: Number, defalt: 2 }, lineHeight: { type: Number, default: 16 }, textAlign: { type: String, default: "center" }, color: { type: String, default: "rgba(72, 108, 149, 1)" }, backgroundColor: { type: String, default: "transpanrent" }, style: { type: Object, defalut: {} }, show: { type: Boolean, default: false }, timeType: { type: String, default: "YYYY-MM-DD hh:mm:ss dddd" } }, setup(props) { hooks.locale("zh-cn"); const timeDateReft = ref(null); const textContent = timeDateReft.value; let timeValue = ref(""); const timeTimer = setInterval(function() { callFormat(); }, 1e3); const callFormat = () => { timeValue.value = hooks().format(props.timeType); }; onMounted(() => { callFormat(); }); const attrs = computed(() => { return { fontSize: props.fontSize + "px", fontWeight: props.fontWeight, fontFamily: props.fontFamily, letterSpacing: props.letterSpacing + "px", textAlign: props.textAlign, color: props.color, backgroundColor: props.backgroundColor, style: props.style, lineHeight: props.lineHeight + "px", display: props.show === false ? "block" : "none" }; }); return { timeTimer, timeValue, timeDateReft, textContent, attrs, ...toRefs(props) }; } }); function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return openBlock(), createElementBlock("div", { class: "co-time-date test", ref: "timeDateReft", style: normalizeStyle(_ctx.attrs), type: "text" }, toDisplayString(_ctx.timeValue), 5); } var LabelText = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-a34d203e"]]); export { LabelText as default };