我想在放大器中创建动态链接。使用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>