需要垫片设置-jquery.flot/jquery.flot.selection
require shim setup- jquery.flot/jquery.flot.selection
所以我正在使用jquery.flot和jquery.flot.selection,由于define({…异步加载模块),我遇到了一个问题,因为选择插件试图将自己推入$.prot.plugins(由jquery.fot创建),但此时$.prot.plugins仍未定义。
我发现require.config中的"shim"参数应该能帮我解决这个问题,但我运气不好。。。下面是概要。。。jquery.flot创建$.plotjquery.flot.selection将自己添加到$.plot.plugins
我尝试过的。。。
shim:{
'js/lib/jquery.flot':{
exports:'$.plot'
},
'js/lib/jquery.flot.selection':{
deps:['js/lib/jquery.flot']
}
}
还有
shim:{
'js/lib/jquery.flot.selection':['js/lib/jquery.flot']
}
我的插件是这样的。。
define(['jquery','lib/jquery.flot','lib/jquery.flot.selection'], function() {
(function($) {
// jQuery plugin definition
.....
我也试过
define(['jquery'],function(){
require[('js/lib/jquery.flot.selection'],function(){
//jQuery plugin definition
...
我该怎么办???
对于将来碰巧遇到这种情况的人来说,RequireJS在诊断问题时可能有点不透明。下面是RequireJS 2的一个工作示例,带有jquery.flot和jquery.flot.selection,没有use模块。
很难说这个例子和上面的问题有什么不同,所以不透明!
require.config({
shim: {
'jquery': {
exports: '$'
},
'jquery.flot': {
deps: ['jquery'],
exports: '$.plot'
},
'jquery.flot.selection': {
deps: ['jquery.flot']
}
},
paths: {
'jquery': '//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min',
'jquery.flot': '//cdnjs.cloudflare.com/ajax/libs/flot/0.8.1/jquery.flot.min',
'jquery.flot.selection': 'https://raw.github.com/flot/flot/master/jquery.flot.selection'
}
});
require(['jquery', 'jquery.flot', 'jquery.flot.selection'], function ($) {
// jQuery plugin definition
console.log($.plot);
$('#x').text($.plot.plugins);
});
相关文章:
- 需要垫片设置-jquery.flot/jquery.flot.selection
- 阻止jQuery Flot将数字转换为十进制
- 可以Flot(或任何其他JQuery图表库)绘制公式
- Firefox SDK:包括jquery.flot在内的问题,错误显示维度高度为空
- JQuery Flot:只需在按住 Shift 键时平移即可
- 如何在 jquery flot 中修剪轴数
- 如何将内容添加到 JQuery Flot 图表数据数组工具提示
- jQuery Flot xaxis Time Format
- jquery flot legend 中的事件处理程序
- jquery flot{mode : time} 未正确给出时间
- 克隆 Jquery Flot 图表
- 使用 jquery flot 绘制 json 数组
- Highstock与 jquery.ba-resize.js和jquery.flot.resize.js冲突
- Jquery Flot “plothover” 事件不起作用
- 在jquery flot图表中,只突出显示一条特定的网格线
- jQuery Flot库的Categories插件不工作
- 用于jquery flot图表的highlightSeries插件
- 将PHP数组转换为javascript数组,传递给jQuery.flot进行绘图
- jquery flot图表不会动态更新时间序列的X轴值
- 如何在jquery flot上向下滚动时冻结、固定标签