我正在尝试在当前的React项目中使用布尔玛日历。我遵循了文档,但是没有用。这是我在componentDidMount
import bulmaCalendar from 'bulma-calendar/dist/js/bulma-calendar.min.js';
import 'bulma-calendar/dist/css/bulma-calendar.min.css'
在componentDidMount中,我只是复制粘贴站点documentation中的示例
componentDidMount() {
var calendars = bulmaCalendar.attach('[type="date"]');
calendars.forEach(calendar => {
// Add listener to date:selected event
calendar.on("date:selected", date => {
console.log(date);
});
});
// To access to bulmaCalendar instance of an element
const element = document.querySelector("#startdate");
if (element) {
// bulmaCalendar instance is available as element.bulmaCalendar
element.bulmaCalendar.on("select", datepicker => {
console.log(datepicker.data.value());
});
}
}
但是这不起作用,它说
“错误:TypeError:document.createRange(...)。_cxualFragment不是功能“
我在做什么错?
import 'bulma-calendar/dist/js/bulma-calendar.min.js';
import 'bulma-calendar/dist/css/bulma-calendar.min.css';
并将这些导入移动到项目的根index.js中,以在您的应用中访问bulmaCalendar函数