簡體   English   中英

TypeError: Object(…) is not a function when add Moment to Bootstrap Date Time Picker

[英]TypeError: Object(…) is not a function when add Moment to Bootstrap Date Time Picker

直截了當,這是我的選擇器的代碼:

import {moment} from 'moment';

const datePicker = () => {
  $('.datetimepicker').datetimepicker({
    format: 'LT',
    locale: 'PT-BR',
    icons: {
      up: "fa fa-chevron-up",
      down: "fa fa-chevron-down",
    },
    stepping: 15,
    disabledTimeIntervals: [[moment({ h: 0 }), moment({ h: 8 })], [moment({ h: 18 }), moment({ h: 24 })]]
  });
};

export {datePicker};

disabledTimeIntervals: [[moment({ h: 0 }), moment({ h: 8 })], [moment({ h: 18 }), moment({ h: 24 })]]直接來自文檔

但是添加它會導致dtPicker.js:24 Uncaught TypeError: Object(...) is not a function

您正在以錯誤的方式導入時刻

import moment from "moment"; // correct way

這個答案是在 10 個月之后,但可能對其他人有所幫助

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM