簡體   English   中英

為什么 data-amp-bind-href 或 [href] 在 amp-bind 組件中不起作用?

[英]Why data-amp-bind-href or [href] don't work in amp-bind component?

我想在放大器中創建一個動態鏈接。 使用amp-bind組件時一切正常,除了將狀態綁定到 href! 我的代碼如下所示:

<input
  on="input-throttled:AMP.setState({ buyForm: { name: event.value } })
  name="name"
  type="text"
/>
<a
  href="localhost:5000/api/v1/buy"
  data-amp-bind-href="'localhost:5000/api/v1/buy?name=' + buyForm.name"
>

您的示例有效(如果您導入 amp-bind 擴展並在 URL 中添加協議)。 這是我嘗試過的:

<head>
    ...
    <script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
</head>
<body>
<input on="input-throttled:AMP.setState({ buyForm: { name: event.value } })" name="name" type="text" />
<a href="https://google.com" data-amp-bind-href="buyForm.name">Test</a>
</body>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM