- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 jspm/SystemJS 导入 jQuery 插件(即 https://github.com/Mottie/Keyboard )。
首先,我只需输入以下命令即可安装该模块:
jspm install github:mottie/keyboard
然后,在导入 jQuery 之后,我在代码中添加了导入库的行:
import keyboard from 'mottie/keyboard';
但是,在运行代码时,我遇到了以下错误:
Uncaught TypeError: Multiple defines for anonymous module
谷歌搜索错误并没有给我提供解决方案,至少没有一个我能理解的解决方案......不知道这里有没有jspm高手可以帮助我? :)
提前非常感谢...
最佳答案
如果您查看 jQuery.keyboard 的源代码,它会在代码中两次使用 UMD 模式:
一次在https://github.com/Mottie/Keyboard/blob/master/js/jquery.keyboard.js#L31 ,并一次访问 https://github.com/Mottie/Keyboard/blob/master/js/jquery.keyboard.js#L2165 .
SystemJS 正在检测该文件为 AMD,但它自己定义了两次而不是一次。
基本上,这不是一个有效的 AMD 模块,因此您需要告诉 SystemJS 将其视为全局模块。
这可以通过覆盖来完成:
jspm install github:mottie/keyboard -o "{format: 'global'}"
即使如此,上面的内容也要求 jQuery 已经加载。为此,我们可以在 jQuery 上添加一个填充程序来强制执行依赖关系。
使用垫片覆盖的标准 jQuery 插件如下所示:
覆盖.json
{
"main": "js/jquery.keyboard.js",
"shim": {
"js/jquery.keyboard": {
"deps": ["jquery"]
}
},
"dependencies": {
"jquery": "*"
}
}
然后我们可以安装它:
jspm install github:mottie/keyboard -o override.json
请将您的覆盖发布到 jspm registry如果成功,其他用户也可以受益。
关于jquery - jspm:导入 jQuery 插件时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29148667/
我正在使用 jspm 0.16.2。 我正在使用这个 test project 当我将 Transpiler 设置为 none 时:transpiler: "none" 我收到一个错误 XHR err
命令 jspm 安装将软件包更新到最新版本? 最佳答案 jspm install安装 package.json 中列出的最新版本的软件包,尊重其中定义的 semver 范围。安装后,确切的版本号(不是
我试图了解在使用 JSPM 安装模块后如何运行可执行文件.例如,如果我运行 jspm install gulp ,那么我希望能够运行以下命令: ./jspm_packages/npm/gulp\@3.
我在 https://github.com/jspm/jspm-cli/wiki/Getting-Started 中安装了 jspm . npm 安装 jspm -g。 它运行。 我称之为:jspm
最近我开始使用 aurelia-framework 并且到目前为止一直很好但是当我编辑 config.js 以添加一些我的文件时不是通过 jspm 安装的东西工作正常我导入我的脚本没有错误但是当我克隆
我对jspm比较陌生。我想知道什么时候运行有什么区别jspm install package和 npm install package .我知道有一个 jspm/registry 的查找。但是在设置
当我安装 css插件,使用以下命令: jspm install css 以下添加到我的 config.js 中: System.config({ "map": { "css": "gith
这篇文章是 stackoverflow 转贴 self 的问题 https://github.com/frankwallis/plugin-typescript/issues/64和 https://
我刚刚在 Mac OS 上使用 npm 全局安装了 jspm (sudo npm install jspm -g)。现在,当我运行 jspm init 时,我看到以下控制台输出: err (jspm)
1)它是克隆 repo 还是从版本中提取?据我所知,它是从发行版中提取的。 2) 这是否可以通过选项以与为特定版本指定 @version 相同的方式覆盖。即我想从发布分支中提取特定的 zip 或只是克
我试图让 JSPM/Karma/Babel/Jasmine 一起工作。但是在运行 karma start 时出现错误 15 04 2016 17:34:02.428:INFO [karma]: Kar
在过去的一个项目中,我将jspm的public baseURL指向了app文件夹。但是,在任何新项目中,当我运行 jspm init 时,它默认为 app 文件夹,但我不想要这个。 我尝试寻找相关文档
我正在迁移一个项目以使用 JSPM 和 SystemJS。在我的应用程序中,我重写 Backbone Marionette 渲染方法以使用 Mustache 模板: Marionette.Render
我在所有项目中都使用 SystemJs 和 JSPM,感觉太棒了。使用前端库变得前所未有的简单,使用 JSPM 我可以通过几个简单的步骤来完成: 命令行:jspm 安装角度 index.ts|js:i
我升级到 --latest 但由于兼容性问题想降级到特定版本。 最佳答案 像这样指定版本号即可。 npm install jspm@1.0.0 关于javascript - 如何降级/安装特定版本的
我开始在我的 Aurelia Web 项目中使用 JSPM,我想知道使用 import "" 是否有任何后果或优势。 ? 我在 JS 类中看到过这样的客户端库代码: import "jquery";
将用 TypeScript 编写的库转换为 ES5 的当前推荐做法是什么? JSPM 文档似乎是针对网络应用程序的(即 jspm bundle-sfx )。 我在 Google 上找到的所有文章似乎都
用于 React 和 JSPM 项目的最佳测试框架及其相关帮助程序库是什么?我正在寻找组合在一起的各种库,以及该库的具体特点是什么使其成为一个强大的工具集? (希望稍后合并 redux) 最佳答案 我
我是 jspm 的新手。我想在我的项目中使用 materialize-css 。我认为理想的使用方式是在使用 jspm (jspm install npm:materialize-css) 安装后使用
所以我做了: $ jspm install github:Eonasdan/bootstrap-datetimepicker $ jspm install npm:moment 然后在我的 js 文件
我是一名优秀的程序员,十分优秀!