这是 index.html 文件中的一个工作示例,您可以在根 Pug/Jade 文件中执行相同的操作。我也使用cdn版本,但您也可以从下载它们的文件夹中导入它们。
window.dayjs_plugin_minmax
vswindow.dayjs_plugin_minMax
可能是问题
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Test page</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="https://unpkg.com/dayjs@1.8.21/dayjs.min.js"></script>
<script src="https://unpkg.com/dayjs@1.8.21/plugin/isBetween.js"></script>
<script src="https://unpkg.com/dayjs@1.8.21/plugin/minMax.js"></script>
</head>
<body></body>
<script>
const minMax = window.dayjs_plugin_minMax;
const isBetween = window.dayjs_plugin_isBetween;
dayjs.extend(minMax);
dayjs.extend(isBetween);
console.log(
"MAX: ",
dayjs.max(dayjs(), dayjs("2018-01-01"), dayjs("2019-01-01"))
);
console.log(
"MIN: ",
dayjs.min(dayjs(), dayjs("2018-01-01"), dayjs("2019-01-01"))
);
console.log(
"BETWEEN: ",
dayjs("2016-10-30").isBetween("2016-01-01", "2016-10-30", null, "[)")
);
</script>
</html>
这是结果: