Использование localalstorage в Google amp - PullRequest
1 голос
/ 04 ноября 2019

Я пытался сохранить некоторые данные в localStorage после ответа amp-form , используя собственный скрипт (amp-script) в форме submit-success на странице amp.

Согласно таблице совместимости API от amp.dev , Window.localStorage разрешен.

Но я получаю Type must be specified ошибку вконсоль с помощью amp-script

type must be specified console error screenshot

Код

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

Любая помощь будет оценена Спасибо

...