我想向我的 AMP 静态网站添加 cookie 同意。我想利用模式对话框amp-story-consent
可以提供给我。我研究了各种例子,也许最完整的是:
(示例文档https://amp.dev/documentation/examples/user-consent/story_user_consent/?referrer=ampbyexample.com https://amp.dev/documentation/examples/user-consent/story_user_consent/?referrer=ampbyexample.com)
我的问题是我只想显示 JSON 片段中定义的标题/消息/供应商
<amp-story-consent id="consentUI" layout="nodisplay">
<script type="application/json">
{
"title": "Headline",
"message": "This is some more information about this choice. Here's a list of items related to this choice.",
"vendors": ["Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6", "Item 7", "Item 8", "Item 9", "Item 10"]
}
</script>
</amp-story-consent>
加上一个接受和一个拒绝按钮。有了 Cookie 同意,我真的没有任何同意故事页 or any 故事书挡,但 AMP 验证规则似乎需要它。这是一个问题。游乐场显示一对拒绝/接受按钮,我想要一对拒绝/接受按钮,但我看不到可以在哪里定义它。
在光秃秃的amp-consent
文档中有按钮(请参阅“同意配置”https://amp.dev/documentation/components/amp-consent/ https://amp.dev/documentation/components/amp-consent/):
<div id="consent-ui">
<button on="tap:consent-element.accept" role="button">Accept</button>
<button on="tap:consent-element.reject" role="button">Reject</button>
<button on="tap:consent-element.dismiss" role="button">Dismiss</button>
</div>
有人有例子或指导吗?
请注意,https://amp.dev/documentation/components/amp-consent/ https://amp.dev/documentation/components/amp-consent/有这个示例片段。它说“示例:在 AMP Story 上显示提示用户界面”
<amp-consent layout="nodisplay" id="consent-element">
<script type="application/json">
{
"consents": {
"my-consent": {
"checkConsentHref": "https://amp.dev/documentation/examples/api/get-consent",
"promptUI": "consent-ui"
}
}
}
</script>
<amp-story-consent id="consent-ui" layout="nodisplay">
<script type="application/json">
{
“title”: "My title",
“message”: "My example message.",
“vendors”: ["Item 1", "Item 2", "Item 3", "Item 4"]
}
</script>
</amp-story-consent>
</amp-consent>
如何让它发挥作用? (正如我提到的,我没有任何故事页 or any 故事书挡正如代码片段所暗示的那样)。