我正在尝试使用requirejs加载stickytableheaders并且似乎无法使其正常工作。总是说没找到它。我已经确认它在使用之前加载了该脚本。
知道为什么$("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());
})
答案 0 :(得分:-1)
我能够让它发挥作用。
我必须将代码添加到视图模型的末尾以获取所需的页面。似乎应该有一种方法可以在全球范围内进行。
$("表&#34)。stickyTableHeaders();