[英]Require.js Uncaught TypeError: undefined is not a function
[英]Require.js/Jquery Datable : undefined is not a function
我正在嘗試使用Require.js加載JQuery數據表
這是我想使用datatables的JS模塊:
define([
"jquery",
"text!orders_list.tpl",
"dataTables"
], function($, OrdersListTemplate, dataTables)
{
console.log($);
console.log($.fn.dataTable);
... more logic after
我如何用HTML調用我的JS模塊:
require(['./js/config'], function (common)
{
require(
[
'js/modules/init',
...
'js/modules/orders_list.js'
],
function (init, ..., orders_list)
{
init.initialize();
...
orders_list.initialize();
});
});
我如何定義我的配置:
require.config({
shim: {
underscore: {
exports: '_'
},
backbone: {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
},
...
},
paths: {
jquery: '../../shops_common/js/lib/jquery-1.9.1',
backbone: '../../shops_common/js/lib/backbone.min',
underscore: '../../shops_common/js/lib/underscore.min',
dataTables: 'http://datatables.net/download/build/nightly/jquery.dataTables'
},
waitSeconds: 300
});
但是$ .fn.dataTable始終是未定義的...知道為什么嗎?
謝謝。
經過大量研究,我找到了解決方案:數據表是一個命名模塊,您必須在需求中使用名稱“數據表”
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.