1
是否可以使用放大器位置觀測器設置AMP狀態?Amp-html - 我可以使用amp-position-observer來調用amp-bind中使用的AMP.setState()嗎?
我曾嘗試下面的代碼沒有成功:
<!doctype html>
<html ⚡>
<head>
<script async="" src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
<script custom-element="amp-position-observer" src="https://cdn.ampproject.org/v0/amp-position-observer-0.1.js" async></script>
</head>
<body>
<p [text]="'Hello ' + foo">Hello World</p>
<div class="spacer"></div>
<amp-position-observer
intersection-ratios="0"
on="enter:AMP.setState({foo: 'amp-bind'})"
layout="nodisplay">
</amp-position-observer>
</body>
</html>
所採用的解決方案在相關的GitHub線程中解釋:https://github.com/ampproject/amphtml/issues/11735 – Gab