[英]How to require tether with webpack?
I have a webpack application I'm using with laravel elixir. 我有一个用于laravel elixir的webpack应用程序。 In this application I have a bootstrap.js
file for initializing all of my libraries. 在此应用程序中,我有一个bootstrap.js
文件,用于初始化我的所有库。 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');
The only issue is, when I go to build this, I get Error: Can't resolve 'tether-drop'
. 唯一的问题是,当我构建它时,出现Error: Can't resolve 'tether-drop'
。 How can I fix this? 我怎样才能解决这个问题?
Thanks! 谢谢!
To use tether, you'll need to make it available on window. 要使用系绳,您需要使其在窗口上可用。
global.Tether = require('tether');
Now, you can use it with another libraries, for examples, with bootstrap@4. 现在,您可以将其与其他库一起使用,例如,与bootstrap @ 4一起使用。 Don't use import. 不要使用导入。
require('bootstrap');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.