【问题标题】:import datatable in parceljs在 parceljs 中导入数据表
【发布时间】:2018-12-05 03:44:34
【问题描述】:

我正在尝试使用parceljs 导入datatables(以及jquery 和moment)。

我已经使用this answer 中的解决方法来导入 jquery。

这是我的文件:

在 index.html 中:

      <table id="tableFlows" class="display" style="width:100%">
        <thead>
          <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>Tiger Nixon</td>
            <td>System Architect</td>
            <td>Edinburgh</td>
            <td>61</td>
            <td>2011/04/25</td>
            <td>$320,800</td>
          </tr>
        </tbody>
      </table>

在 index.js 中:

import "./styles.scss";
import "@fortawesome/fontawesome-free/js/all";

import './workaround/import-jquery';
import './workaround/import-moment';

import 'moment-timezone';
import "tempusdominus-bootstrap-4";

import 'datatables.net-dt';

import "./flows.js";

在控制台中,我看到了这个错误:

错误来自flows.js:

$('#datetimepicker1').datetimepicker();
$('#datetimepicker2').datetimepicker();

$('#buttonGo').on('click', function() {
  const moment1 = $("#datetimepicker1").datetimepicker('date');
  const moment2 = $('#datetimepicker2').datetimepicker('date');

  console.log(moment1.format('X'), moment2.format('X'));
});

$("#tableFlows").DataTable();

请帮忙。

【问题讨论】:

标签: datatables parceljs


【解决方案1】:

在您的 index.js 中,使用 require( 'datatables.net-dt' )(); 而不是您的 import

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-08
    • 2020-11-29
    • 2019-03-12
    相关资源
    最近更新 更多