如何要求使用webpack系绳? [英] How to require tether with webpack?

查看:117
本文介绍了如何要求使用webpack系绳?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a webpack application I'm using with laravel elixir. In this application I have a bootstrap.js file for initializing all of my libraries. Here it is:

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'.我该如何解决?

The only issue is, when I go to build this, I get Error: Can't resolve 'tether-drop'. How can I fix this?

谢谢!

推荐答案

要使用系绳,您需要在窗口上使用它.

To use tether, you'll need to make it available on window.

global.Tether = require('tether');

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

Now, you can use it with another libraries, for examples, with bootstrap@4. Don't use import.

require('bootstrap');

这篇关于如何要求使用webpack系绳?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆