为什么光滑的轮播不使用browserify? [英] why is slick carousel not working with browserify?

查看:58
本文介绍了为什么光滑的轮播不使用browserify?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用光滑的旋转木马( http://kenwheeler.github.io/slick/ )并安装通过npm。

I'm trying to use slick carousel (http://kenwheeler.github.io/slick/) and installed via npm.

通过浏览器这样包括它:

Including it via browserify like this:

slick = require('slick-carousel')

试图像这样运行:

$('.gallery__carousel').slick();

没有控制台错误,轮播未初始化。发生了什么?

No console errors, carousel not initialising. What's going on?

推荐答案


注意:不建议编辑库。如果仍然需要
a解决方法,那么你可以按照以下方式进行操作。

NOTE: It's not recommended to edit library. If still in case you want a workaround then you can follow like below.

我使用光滑时也遇到了同样的问题使用browserify但没有一个解决方案适合我。然后我把slick转入slick.js并更改 -

I also had the same problem with using slick with browserify but none of solutions worked for me. Then i take a took into slick.js and changed -

查找:

(function(factory) {
    'use strict';
    if (typeof define === 'function' && define.amd) {
        define(['jquery'], factory);
    } else if (typeof exports !== 'undefined') {
        module.exports = factory(require('jquery'));
    } else {
        factory(jQuery);
    }

}(function($) {

替换:

;(function ( $, window, document, undefined ) {

添加最后一行 -

查找:

}));

替换:

})( jQuery, window, document );

希望有助于理解这个问题。

Hope it helps to understand the problem.

这篇关于为什么光滑的轮播不使用browserify?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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