在使用安培页面的表单amp-form中的自定义脚本(amp-script)响应submit-success之后,我一直试图在localStorage上存储一些数据。
根据API compatibility table的amp.dev,允许Window.localStorage。
但是我使用amp-script在控制台中出现Type must be specified
错误
代码
<form
method="post"
target="_top"
classname="body"
action-xhr={`//localhost:4000/check-user`}
custom-validation-reporting="show-all-on-submit" >
----------------------
----- form inputs ----
----------------------
<div classname="success_message" submit-success="true">
<amp-script width="200" height="50" script="store_data"></amp-script>
<script id="store_data" type="text/plain" target="amp-script">
Window.localstorage.setItem("__t",randomGUID(19)); // randomGUID returns a random alphanumeric string of specified length
</script>
</div>
</form>
任何帮助将不胜感激 谢谢