javascript - 如何使用 browserify 请求 jQuery.loadTemplate

标签 javascript jquery gulp browserify

我已经使用 Gulp 设置了 browserify。

当我需要 jQuery 时,一切正常:

var $ = require('jquery');

当我尝试要求 jquery 加载模板模块时

var loadTemplate = require('jquery.loadtemplate')

我收到错误

module "jquery.loadtemplate " not found

我像这样使用npm安装了loadtemplate

npm install --save jquery.loadtemplate 

最佳答案

我认为 jquery.loadtemplate 模块的 package.json 中有错误。它应该在某处定义插件的来源,但它丢失了。在其他模块中,源在“main”属性中定义。它应该说类似

“main”:“jquery-loadTemplate/jquery.loadTemplate-1.5.0.js”,

取决于脚本文件的位置。您可以手动更改它,但下次更新/重新安装 npm 包时它将被删除。

关于javascript - 如何使用 browserify 请求 jQuery.loadTemplate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30467628/

相关文章:

javascript - 将事件从 iframe 传递到父级

javascript - 如何使用PHP强制下载文件?

javascript - 如何使用 javascript 添加特定对象?

jquery - 如何将 Google Places API 绑定(bind)到仅限美国的地址?

一口哈巴狗 : compile new on changed files only (case with "includes" and "extends")

meteor - 如何告诉 Meteor 忽略 `gulpfile.js`

javascript - LeafletJS & Cloudmade : Retina Tile Support

javascript - 如何使用 jQuery 检查日期与当前日期

javascript - 如何在页面刷新时保持选定/事件的 HTML 链接颜色?

javascript - Gulp 浏览器同步只工作一次