gpt4 book ai didi

javascript - OJET 网格不显示

转载 作者:行者123 更新时间:2023-11-30 21:03:29 27 4
gpt4 key购买 nike

我是第一次试用 OJET。它是一个渐变项目。我有一个按钮(重定向到一个 servlet)和一个 oj-data-grid。在运行 gradlew appRun 时一切正常,但未显示网格。这是我的代码:

index.html

<!DOCTYPE>
<html>
<head>
<title>My Web Page</title>
</head>
<body>
<form method="post" action="dataServlet">
<input type="submit" value="Click"/>
</form>
<div id="oj-grid-example">
ABCD <br/>
<oj-data-grid id="datagrid"
style="width:100%;max-width:234px;height:130px"
aria-label="Data Grid Cell Based Grid Demo"
data="[[dataSource]]">
</oj-data-grid>
<br/>EFGH
</div>
</body>
</html>

主要.js

requirejs.config({
paths: {
'knockout': 'libs/knockout/knockout-3.4.0',
'jquery': 'libs/jquery/jquery-3.1.1.min',
'jqueryui-amd': 'libs/jquery/jqueryui-amd-1.12.0.min',
'ojs': 'libs/oj/v4.0.0/min',
'ojL10n': 'libs/oj/v4.0.0/ojL10n',
'ojtranslations': 'libs/oj/v4.0.0/resources',
'text': 'libs/require/text',
'promise': 'libs/es6-promise/es6-promise.min',
'hammerjs': 'libs/hammer/hammer-2.0.8.min',
'signals': 'libs/js-signals/signals.min',
'ojdnd': 'libs/dnd-polyfill/dnd-polyfill-1.0.0.min',
'css': 'libs/require-css/css.min',
'customElements': 'libs/webcomponents/custom-elements.min',
'proj4': 'libs/proj4js/dist/proj4'
},
shim: {
'jquery': {
exports: ['jQuery', '$']
}
},

config: {
ojL10n: {
merge: {
//'ojtranslations/nls/ojtranslations': 'resources/nls/myTranslations'
}
},
text: {
useXhr: function (url, protocol, hostname, port) {
return true;
}
}
}
});


require(['ojs/ojcore', 'knockout', 'jquery', 'ojs/ojknockout', 'promise',
'ojs/ojdatagrid', 'ojs/ojarraydatagriddatasource'],
function(oj, ko, $)
{
function viewModel()
{
var self = this;
var dataArray = [
['1', '2', '3'],
['4', '5', '6'],
['7', '8', '9']
];
self.dataSource = new oj.ArrayDataGridDataSource(dataArray);
}

$(
function()
{
ko.applyBindings(new viewModel(), document.getElementById('datagrid'));
}
);
});

构建.gradle

plugins {
id 'java'
id 'war'
id 'org.akhikhl.gretty' version '1.4.2'
}

sourceCompatibility = 1.8

repositories {
mavenCentral()
}

dependencies {
providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
testCompile group: 'junit', name: 'junit', version: '4.12'
}

输出

Click [Imagine this as a clickable button. This part of the code works]
ABCD

EFGH

如输出所示,未显示数据网格。

gradle.build 是否需要特殊配置?

最佳答案

是否添加脚本标签进行初始化?试试这个:-

<link href="css/libs/oj/v4.0.0/alta/oj-alta-min.css"
rel="stylesheet"
type="text/css"/>
<script data-main="js/main"
src="js/libs/require/require.js">
</script>

关于javascript - OJET 网格不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46875448/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com