在Google amp中使用Localstorage 代码

在使用安培页面的表单amp-form中的自定义脚本(amp-script)响应submit-success之后,我一直试图在localStorage上存储一些数据。

根据API compatibility tableamp.dev,允许Window.localStorage。

但是我使用amp-script在控制台中出现Type must be specified错误

在Google amp中使用Localstorage
      
    代码


代码

<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>

任何帮助将不胜感激 谢谢

zhaoqiyun59240 回答:在Google amp中使用Localstorage 代码

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3168677.html

大家都在问