我正在尝试使用数组作为数据源,使用 HtmlService 和用于 jquery 的 Datatables 插件。我在传递数组时遇到问题。结果表未正确呈现数组 - 在此 3 col 表中,col1 包含“1”,col2 包含“,”col3 包含“2”我做错了什么?
function doGet() {
var temp = HtmlService.createTemplateFromFile('example2');
temp.j = [1,2,3];
return temp.evaluate();
}
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>DataTables example</title>
<link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.1/css/jquery.dataTables.css">
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.min.js"></script>
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.1/jquery.dataTables.min.js"></script>
<script type="text/javascript" charset="utf8">
$(document).ready(function() {
$('#demo').html( '<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"></table>' );
$('#example').dataTable( {
"aaData": [
/* Reduced data set */
<?= j ?>
],
"aoColumns": [
{ "sTitle": "Engine" },
{ "sTitle": "Browser" },
{ "sTitle": "Platform" }
]
} );
} );
</script>
</head>
<body>
<div id="demo"></div>
</body>
</html>