【问题标题】:How to require tether with webpack?如何使用 webpack 要求系绳?
【发布时间】:2017-04-29 08:52:12
【问题描述】:

我有一个与 laravel elixir 一起使用的 webpack 应用程序。在这个应用程序中,我有一个 bootstrap.js 文件用于初始化我的所有库。这里是:

window._ = require('lodash');

/**
 * We'll load jQuery and the Bootstrap jQuery plugin which provides support
 * for JavaScript based Bootstrap features such as modals and tabs. This
 * code may be modified to fit the specific needs of your application.
 */

window.$ = window.jQuery = require('jquery');// $ui = require("jquery-ui");
/**
 * import twitter bootstrap js library
 */
require('bootstrap-sass');
/**
 * import jquery ui
 */
require('jquery-ui-bundle');

/**
 * import jquery datatables
 */
require('datatables.net');

/**
 * import select2
 */
require('select2'); // globally assign select2 fn to $ element

/**
 * import d3
 */
require('d3');

/**
 dropdowns
 */
require('tether');
require('tether-drop');

唯一的问题是,当我去构建它时,我得到了Error: Can't resolve 'tether-drop'。我该如何解决这个问题?

谢谢!

【问题讨论】:

  • 我删除了elixir,因为它是一个标记与编程语言相关的问题的标签。
  • @mudasobwa,这是一个重要的标签,因为它意味着不能使用传统的 webpack 中使用的配置文件
  • 哦,我明白你的意思了,让我改一下吧。

标签: javascript npm webpack amd laravel-elixir


【解决方案1】:

要使用系绳,您需要使其在窗口中可用。

global.Tether = require('tether');

现在,您可以将它与其他库一起使用,例如 bootstrap@4。不要使用导入。

require('bootstrap');

【讨论】:

    猜你喜欢
    • 2017-06-23
    • 1970-01-01
    • 2015-11-01
    • 2016-04-03
    • 2017-05-19
    • 1970-01-01
    • 2015-06-23
    • 2017-03-18
    • 1970-01-01
    相关资源
    最近更新 更多