javascript - 如何在 javascript 函数中访问 Mustache 文件 [更新]?
问题描述
我有一些数据存储在 java 代码中的 ArrayList 中,我正在使用 Mustache 在我的 HTML 网页上显示 myArray 的结果。
myIndex.html 文件:
<html>
<head>
<script>
var plotMapHidden = true;
{{{myArray}}}
</script>
</head>
<body>
<div class="card-body">
{{#myArray}}
<strong> {{.}} </strong> <br>
{{/myArray}}
</div>
<script >
// I want to access {{myArray}} data here as well like var newArray = {{myArray}}
</script>
</body>
</html>
有什么方法可以访问脚本中的 Mustache 数据,如上所示?
HTML 成功输出了 div 部分([1,2,...,100]
)。我想重用部分中的 myArray 数据以及执行其他 javascript 函数。谢谢
解决方案
推荐阅读
- c++ - Segmentation fault in array storing in IPC linux
- reactjs - 如何在反应中集中输入日期字段?
- android - how to get Dagger2 Compiler Options working?
- pandas - What is the most efficient way of storing a list inside pandas column?
- arrays - 无法在 Swift 4 中使用 firstIndex:where
- verilog - 为什么iverilog 抱怨这个表达式/端口宽度?
- sql - 数据表中的自定义分页
- python - Unable to use "scheme" attribute when plot GeoDataFrame
- css - 是否值得为 IE 或任何其他旧版本指定某些属性?[向后兼容]
- ios - Swift - 在我的项目中获得零,而我正在尝试通过 cellForItem 访问项目