【问题标题】:TypeError: Object(...) is not a function when add Moment to Bootstrap Date Time PickerTypeError: Object(...) is not a function when add Moment to Bootstrap Date Time Picker
【发布时间】:2020-06-07 00:26:48
【问题描述】:

直截了当,这是我的选择器的代码:

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 })]] 的行直接来自the documentation

但添加它会导致dtPicker.js:24 Uncaught TypeError: Object(...) is not a function

【问题讨论】:

    标签: javascript bootstrap-4 momentjs bootstrap-datetimepicker


    【解决方案1】:

    你输入错误的方式

    import moment from "moment"; // correct way
    

    这个答案是 10 个月后的,但可能对其他人有所帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-23
      • 1970-01-01
      • 1970-01-01
      • 2018-11-16
      • 2019-04-05
      • 2019-01-30
      • 2020-08-03
      • 1970-01-01
      相关资源
      最近更新 更多