Javascript 未捕获(承诺中)引用错误:未定义ViewModel
我试图使用Oracle OJET工具,使用data.JSON文件中存储的伪JSON数据显示一个表。 一切正常,但在控制台日志中我看到以下错误: 未捕获(承诺中)引用错误:未定义ViewModel 大约在.js:36 . 我无法理解这个错误是什么以及如何解决它,有人能帮忙吗 关于.js文件:Javascript 未捕获(承诺中)引用错误:未定义ViewModel,javascript,html,Javascript,Html,我试图使用Oracle OJET工具,使用data.JSON文件中存储的伪JSON数据显示一个表。 一切正常,但在控制台日志中我看到以下错误: 未捕获(承诺中)引用错误:未定义ViewModel 大约在.js:36 . 我无法理解这个错误是什么以及如何解决它,有人能帮忙吗 关于.js文件: define(['accUtils', 'knockout', 'ojs/ojbootstrap', 'ojs/ojarraydataprovider','text!data/data.json',
define(['accUtils', 'knockout', 'ojs/ojbootstrap', 'ojs/ojarraydataprovider','text!data/data.json',
'ojs/ojtable','ojs/ojknockout'],
function(accUtils, ko, ojbootstrap_1, ArrayDataProvider, data) {
function AboutViewModel() {
var self = this;
self.stackValue = ko.observable("off");
self.orientationValue = ko.observable("vertical");
self.dataProvider = new ArrayDataProvider(JSON.parse(data), {
keyAttributes: "id",
implicitSort: [{ attribute: "id", direction: "ascending" }],
});
ojbootstrap_1.whenDocumentReady().then(function () {
ko.applyBindings(new ViewModel(), document.getElementById("table"));
});
return AboutViewModel;
}
);
关于.html文件:
<div class="oj-hybrid-padding">
<h1>About Content Area</h1>
<div>
To change the content of this section, you will make edits to the about.html file located in the /js/views folder.
</div>
<oj-table id='table' aria-label='Departments Table'
data='[[dataProvider]]'
selection-mode='{"row": "multiple", "column": "multiple"}'
dnd='{"reorder": {"columns": "enabled"}}'
scroll-policy='loadMoreOnScroll'
scroll-policy-options='{"fetchSize": 10}'
columns='[{"headerText": "Id",
"field": "id",
"headerClassName": "oj-sm-only-hide",
"className": "oj-sm-only-hide",
"resizable": "enabled"},
{"headerText": "Series",
"field": "series",
"resizable": "enabled"},
{"headerText": "Group",
"field": "group",
"headerClassName": "oj-sm-only-hide",
"className": "oj-sm-only-hide",
"resizable": "enabled"},
{"headerText": "Value",
"field": "value",
"resizable": "enabled"}]'
class='demo-table-container oj-bg-body'>
</oj-table>
</div>
<style>
.demo-table-container {
width: 100%;
height: 112.5rem;
}
</style>
关于内容区
要更改此部分的内容,您将编辑位于/js/views文件夹中的about.html文件。
.演示表容器{
宽度:100%;
身高:112.5雷姆;
}