🐛(component): 修复 layer 在 google 高版本中的警告信息

This commit is contained in:
就眠儀式 2022-10-10 23:35:01 +08:00
parent 98ca6a61b5
commit 2f52cc2739
4 changed files with 16 additions and 14 deletions

View File

@ -133,7 +133,7 @@ export interface LayDatePickerProps {
size?: "lg" | "md" | "sm" | "xs"; size?: "lg" | "md" | "sm" | "xs";
prefixIcon?: string; prefixIcon?: string;
suffixIcon?: string; suffixIcon?: string;
timestamp?:boolean timestamp?: boolean;
} }
const props = withDefaults(defineProps<LayDatePickerProps>(), { const props = withDefaults(defineProps<LayDatePickerProps>(), {
@ -148,7 +148,7 @@ const props = withDefaults(defineProps<LayDatePickerProps>(), {
size: "md", size: "md",
prefixIcon: "layui-icon-date", prefixIcon: "layui-icon-date",
suffixIcon: "", suffixIcon: "",
timestamp:false timestamp: false,
}); });
const dropdownRef = ref(null); const dropdownRef = ref(null);
@ -304,8 +304,8 @@ watch(
props.range && props.modelValue props.range && props.modelValue
? (props.modelValue as string[])[0] || "" ? (props.modelValue as string[])[0] || ""
: (props.modelValue as string); : (props.modelValue as string);
if(props.type==='month'||props.type==='year'){ if (props.type === "month" || props.type === "year") {
initModelValue+=''; initModelValue += "";
} }
hms.value.hh = isNaN(dayjs(initModelValue).hour()) hms.value.hh = isNaN(dayjs(initModelValue).hour())
@ -333,7 +333,9 @@ watch(
if (currentYear.value === -1) currentYear.value = dayjs().year(); if (currentYear.value === -1) currentYear.value = dayjs().year();
if (currentMonth.value === -1) currentMonth.value = dayjs().month(); if (currentMonth.value === -1) currentMonth.value = dayjs().month();
if (props.timestamp) { if (props.timestamp) {
currentDay.value = initModelValue ? dayjs(parseInt(initModelValue)).startOf('date').unix()*1000 : -1; currentDay.value = initModelValue
? dayjs(parseInt(initModelValue)).startOf("date").unix() * 1000
: -1;
} }
} }
rangeValue.first = initModelValue; rangeValue.first = initModelValue;
@ -371,6 +373,6 @@ provide("datePicker", {
rangeValue: rangeValue, rangeValue: rangeValue,
rangeSeparator: props.rangeSeparator, rangeSeparator: props.rangeSeparator,
simple: props.simple, simple: props.simple,
timestamp:props.timestamp timestamp: props.timestamp,
}); });
</script> </script>

View File

@ -4,7 +4,7 @@ const useMove = function (el: HTMLElement, callback: Function) {
let offsetY: number; let offsetY: number;
if (el != null) { if (el != null) {
el.addEventListener("mousedown", function (event: any) { el.addEventListener("mousedown", function (event: any) {
const path = event.path || (event.composedPath && event.composedPath()); const path = event.composedPath();
if (path[0].className === "layui-layer-title") { if (path[0].className === "layui-layer-title") {
if (event.button == 0 && el != null) { if (event.button == 0 && el != null) {
const lexObj: any = getComputedStyle(el); const lexObj: any = getComputedStyle(el);

View File

@ -1,7 +1,7 @@
const useMove = function (el: HTMLElement, callback: Function) { const useMove = function (el: HTMLElement, callback: Function) {
if (el != null) { if (el != null) {
el.addEventListener("mousedown", function (event: any) { el.addEventListener("mousedown", function (event: any) {
const path = event.path || (event.composedPath && event.composedPath()); const path = event.composedPath();
if (path[0].className === "layui-layer-resize") { if (path[0].className === "layui-layer-resize") {
if (event.button == 0 && el != null) { if (event.button == 0 && el != null) {
var x = el.offsetLeft; var x = el.offsetLeft;