【问题标题】:module.exports a jQuery Pluginmodule.exports 一个 jQuery 插件
【发布时间】:2015-05-09 05:24:49
【问题描述】:

我正在尝试module.exports 一个 jQuery 插件(用于 Browserify),但我遇到了一些困难。这是jquery.adaptive-backgrounds 插件,我正在尝试将require() 作为一个模块。

我当前的设置如下所示:

adaptive-backgrounds.js

module.exports = {
  /* adaptive-backgrounds script goes here */
  ;(function($){
  ...
}

app.js

var $ = require('jquery/dist/jquery');
var ab = require('./vendors/adaptive-backgrounds');

$(function() {
  $.ab.run();
});

无论出于何种原因,脚本都没有运行。我显然做错了什么。

如果有人对此有任何经验,我将非常感谢您的帮助。

提前致谢!

【问题讨论】:

标签: javascript jquery browserify


【解决方案1】:

adaptive-backgrounds.js 的内容看起来不像是有效的 JS。

你可能只需要这样的东西:

adaptive-backgrounds.js:

var jQuery = require('jquery');

/* adaptive-backgrounds script goes here */
;(function($){
...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-20
    相关资源
    最近更新 更多