我的角度项目有 2 个问题: 1-我将我的角度版本从 13 更新到 15.2.1 和新版本的 ngx-daterangepicker-material 现在它坏了,这是我得到的错误: core.mjs:8453 错误类型错误:无法读取未定义的属性(读取“selectedHour”) 在 DaterangepickerComponent_div_3_div_3_Template (ngx-daterangepicker-material.mjs:1116:8214)
所以我不得不降级它以避免这个错误
2-我将 dayjs 与 ngx-daterangepicker-material 一起使用,当我从“dayjs/esm”导入 dayjs 时,minDate 和 maxDate 在 datepicker 中不起作用
import dayjs from 'dayjs/esm';
import customParseFormat from 'dayjs/esm/plugin/customParseFormat';
import isoWeek from 'dayjs/esm/plugin/isoWeek';
import localeData from 'dayjs/esm/plugin/localeData';
import localizedFormat from 'dayjs/esm/plugin/localizedFormat';
import weekOfYear from 'dayjs/esm/plugin/weekOfYear';
import objectSupport from 'dayjs/esm/plugin/objectSupport';
import isBetween from 'dayjs/esm/plugin/isBetween';
dayjs.extend(customParseFormat);
dayjs.extend(isoWeek);
dayjs.extend(localeData);
dayjs.extend(localizedFormat);
dayjs.extend(weekOfYear);
dayjs.extend(objectSupport);
dayjs.extend(isBetween);
export default dayjs;
并从此文件中导入 dayjs
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const { AngularWebpackPlugin } = require('@ngtools/webpack');
const path = require('path');
module.exports = {
entry: {
main: './src/main.ts',
},
output: {
globalObject: 'self',
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist'),
},
resolve: {
extensions: ['.ts', '.js'],
alias: {
dayjs: path.resolve(__dirname, 'node_modules/dayjs/esm'), // Add this line
},
},
module: {
rules: [
{
test: /\.ts$/,
loader: '@ngtools/webpack',
},
],
},
plugins: [
new AngularWebpackPlugin({
tsconfig: './tsconfig.app.json',
}),
new MiniCssExtractPlugin({
filename: '[name].css',
}),
],
};
我希望 ngx-datepicker 与 dayjs 兼容,即使我使用 esm 导入它