express - 在加载时使用 amp-bind 或 amp-state 初始化 amp-list
问题描述
我们正在使用 express + EJS 引擎。我想使用 amp-state 和 amp-bind 使用包含 amp-list 项的 EJS 变量初始化我的 amp-list。搜索后我意识到: amp-bind 表达式不会在页面加载时进行评估。但我需要它。我怎样才能拥有一个带有初始化项目和无限加载更多功能的放大器列表?
<amp-state id="localState">
<script type="application/json">
{
"items": [{"id": 1}, {"id": 2}, {"id": 2}]
}
</script>
</amp-state>
<amp-list src="amp-state:localState">
<template type="amp-mustache">
<li>{{id}}</li>
</template>
</amp-list>
此列表在加载时没有任何项目。
解决方案
推荐阅读
- python - 当通过 APIView 类请求 GET 方法时,如何从 API 响应中删除 \n 或以适当的 JSON 格式获取响应
- arrays - 如何在结构中打印无符号字符数组的内容?
- java - 如何在 Android 上水平居中 ListPopupWindow/Other 视图?
- typescript - 对象可能为空。打字稿错误
- reactjs - Create-react-app 从终端启动,但不是 vs-code
- go - 无法安装 bleve,在任何地方都找不到包“github.com/blevesearch/zap/v11”
- php - 从 PHP 应用程序写入 Azure SQL 数据库
- vscode-remote - 如何使用 `code` 命令连接到远程 SSH 主机?
- swift - 从表格视图转到表格视图,但根据选择的单元格显示表格视图的不同数据
- c# - 将报告作为 html 导出到 Outlook 邮件时的嵌入图像