我使用kendo(2017)和requireJS作为我的项目。当我尝试加载以下示例时,它会在出错后给出错误。
Uncaught TypeError: $(...).kendoDropDownList is not a function
代码: -
<!DOCTYPE HTML><html>
<head>
<link rel="stylesheet" href="js/styles/kendo.common.core.min.css" />
<link rel="stylesheet" href="js/styles/kendo.default.min.css" />
<!-- Include RequireJS -->
<script src="http://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.1/require.js"></script>
</head>
<body>
<select id="dropdownlist"></select>
<script>
require.config({
paths: {
"jquery": "http://code.jquery.com/jquery-1.9.1.min"
}
});
console.log(require.config);
require([ "jquery", "js/kendo.all.min" ], function($, kendo) {
console.log(kendo)
$("#dropdownlist").kendoDropDownList({
dataSource: {
data: [{name:"Jane Doe", value: 1}, {name:"John Doe", value: 2}]
},
dataTextField: "name",
dataValueField: "value"
});
});
</script>
</body>
但是当我添加baseURL并按如下方式更改配置时,它可以工作。
require.config({
baseUrl: "js", // the path where the kendo scripts are present
paths: {
"jquery": "http://code.jquery.com/jquery-1.9.1.min",
}
});
require([ "jquery", "kendo.dropdownlist.min" ], function($, kendo) {
console.log(kendo)
$("#dropdownlist").kendoDropDownList({
dataSource: {
data: [{name:"Jane Doe", value: 1}, {name:"John Doe", value: 2}]
},
dataTextField: "name",
dataValueField: "value"
});
});
我试着想出来。但找不到任何解决方案。