AMP 如何在 amp-list 的项目上使用 amp-bind setState

问题描述

我想更新购物车中产品的数量。由于样式的原因,我不想使用认的输入类型编号,因此在我的文本输入周围有 2 个按钮来更新数量

这是我的状态:

  <amp-state id="checkout" src="/api/shopify/checkout" [src]="/api/shopify/checkout"></amp-state>

这是我的表格和清单:

<form method="POST"
      id="form"
      action-xhr="/api/shopify/checkout"
      encType="application/x-www-form-urlencoded"
      target="_top"
      on="submit-success: AMP.setState({checkout: event.response})">
    <amp-list src="/api/shopify/checkout"
              [src]="checkout.items"
              width="300"
              height="600"
              layout="fill"
              binding="refresh">
        <template type="amp-mustache">
            <button on="tap:AMP.setState({ quantity: quantity - 1 })">-</button>
                <input type="text"
                       name="{{ variantId }}"
                       value="{{ quantity }}"
                       pattern="[0-999]"
                       on="change:form.submit" />
            <button on="tap:AMP.setState({ quantity: quantity + 1 })">+</button>
        </template>
    </amp-list>
</form>

我想更新我的项目的数量,然后我假设我的文本输入的 on="change:form.submit" 将调用我的服务器的刷新并更新数据。如果我更新输入,它已经工作,只是不是按钮状态。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)