module.exports一个jQuery插件

module.exports a jQuery Plugin

本文关键字:插件 jQuery 一个 exports module      更新时间:2023-09-26

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

我当前的设置如下:

自适应背景.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();
});

不管出于什么原因,脚本都没有运行。我显然做错了什么。

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

提前感谢!

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

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

adaptive-backgrounds.js:

var jQuery = require('jquery');
/* adaptive-backgrounds script goes here */
;(function($){
...