简体   繁体   English

amp-bind 无法在内部更改 AMP Story 中元素的 class

[英]amp-bind not working inside to change an element's class inside AMP Story

I have created a sidebar inside an AMP Story Page.我在 AMP 故事页面中创建了一个侧边栏。

Inside the sidebar i have a menu with links and sub menus.在侧边栏中,我有一个带有链接和子菜单的菜单。 I am trying to add an "active" class to submenu items when their parent is clicked using this code当使用此代码单击父项时,我正在尝试将“活动” class 添加到子菜单项

<div class="caret" on="tap:AMP.setState({sidebar.openMenu: 1})">

And grabbing the toggle in the submenu item with并抓住子菜单项中的切换

<ul [class]="sidebar.openMenu ? 'active' : ''" class="subMenu">

The problem is that when i tap the parent Menu item, a console error问题是当我点击父菜单项时,控制台错误

AMP.setState is not whitelisted AMP.setState 未列入白名单

appears and nothing changes.出现并且没有任何变化。

How can i whitelist the AMP.setState action inside the AMP Story Page sidebar?如何将 AMP 故事页面侧边栏中的 AMP.setState 操作列入白名单?

You don't need amp-bind to create a multi-level amp-sidebar navigation, use AMP actions and events instead.您不需要amp-bind来创建多级amp-sidebar导航, 而是使用 AMP 操作和事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM