如何在amp-story-consent的帮助下构建AMP cookie同意? [英] How to construct AMP cookie consent with the help of amp-story-consent?
问题描述
我想向我的AMP静态网站添加cookie同意.我想利用amp-story-consent
可以提供给我的模式对话框.我研究了各种示例,也许最完整的示例是这样:
I'd like to add a cookie consent to my AMP static website. I'd like to take advantage of the modal dialog what the amp-story-consent
could provide to me. I studied various examples, maybe the most complete is this:
https://amp.dev/documentation/examples/user-同意/story_user_consent/?referrer=ampbyexample.com )
我的问题是我只想显示JSON代码段中定义的标题/消息/供应商
My problem is that I only want to display the title / message / vendors defined in the JSON snippet
<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同意的情况下,我实际上并没有任何故事页面或任何故事书挡,但是AMP验证规则似乎是必需的.那是一个问题.操场上显示了拒绝/接受"按钮对,我想要拒绝/接受"对,但是我看不到可以在哪里定义.
plus an Accept and a Reject button. With a Cookie consent I don't really have any story pages or any story bookend, but the AMP validation rules seems to require it. That's one problem. The playground shows a Decline / Accept button pair, I'd like a Reject / Accept pair but I don't see where this can be defined.
在amp-consent
裸露的文档中有一些按钮(请参见 https ://amp.dev/documentation/components/amp-consent/):
In the bare amp-consent
documentation there are buttons (see "Consent configuration" at 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/具有此示例代码段.上面写着示例:在AMP故事上显示提示用户界面"
Note that the https://amp.dev/documentation/components/amp-consent/ has this example snippet. It says "Example: Displays a prompt user interface on an 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>
如何使它工作? (正如我提到的,我也没有如代码段所示的任何故事页面或任何故事书挡.)
How to get that working? (As I mentioned I don't have any story pages or any story bookend as the snippet suggests as well).
推荐答案
您不能在amp-story
之外使用amp-story-consent
,因为amp-story
必须具有一定数量的amp-story-page
元素.
You cannot use amp-story-consent
outside of an amp-story
, which must have some number of amp-story-page
elements.
这篇关于如何在amp-story-consent的帮助下构建AMP cookie同意?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!