我正在尝试加载stickytableheaders使用 requirejs 似乎无法让它工作。总是说没找到。我已确认它在使用该脚本之前加载了该脚本。
知道为什么 $("table").stickyTableHeaders();
会抛出 undefined is not a function
错误吗?
配置文件
var require = {
baseUrl: "/",
paths: {
"bootstrap": "Scripts/bootstrap/bootstrap",
"jquery": "Scripts/jquery/jquery-1.9.1",
"stickyTableHeaders": "Scripts/stickyheader/stickyheader",
"knockout": "Scripts/knockout/knockout-3.3.0",
"text": "Scripts/require/text",
"domReady": "Scripts/require/domReady"
},
shim: {
"bootstrap": {
deps: ["jquery"]
},
'stickyTableHeaders': {
deps: ['jquery'],
exports: 'jQuery.fn.stickyTableHeaders'
}
}
}
启动文件
require(['jquery'
, 'knockout'
, 'Scripts/App/components/appViewModel'
, 'stickyTableHeaders'
, 'bootstrap'
, '/Scripts/knockout/bindinghandlers.js'
, 'domReady!']
, function ($, ko, appViewModel, stickyTableHeaders) {
ko.components.register('reportingline', { require: 'Scripts/App/components/reportingline/line' });
ko.components.register('newrpt', { require: 'Scripts/App/components/newrpt/newreport' });
$("table").stickyTableHeaders();
ko.applyBindings(new appViewModel());
})
最佳答案
我能够让它工作。
我必须将代码添加到需要它的页面的 View 模型的末尾。似乎应该有一种方法可以在全局范围内做到这一点。
$("table").stickyTableHeaders();
关于javascript - 使用 StickyTableheaders 且 requirejs 未加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29756161/