液体:使用动态变量作为ARIA扩展的属性

发布于 2025-01-23 19:24:43 字数 675 浏览 2 评论 0原文

我有一个带标签的液体页面。这是下拉菜单的一个元素,因此可以扩展。为此,我想添加atia扩展的属性。

方案 - 用户悬停菜单信息:aria-expanded = true,on blur aria-expanded = falseARIA扩展的应该是动态的。

我的摘要:

<li>
  {% assign menuExpanded = false %}
  <a class="ch-wp-menu-item-link" 
    href="{{item.value}}"
    onclick="return cityHiveMenuItemLinkClicked(event)"
    onmouseover={% assign menuExpanded = true %}
    onblur="{{menuExpanded = false}}"
    aria-expanded="{{menuExpanded}}">
    My menu item
  </a>
</li>

我遇到的问题是,我不能仅使用&lt; script&gt;标签,在那里创建一个变量,然后在模板本身中使用它。

这里有什么解决方案?谢谢你!

I have a liquid page with the tag . This is an element of the drop-down menu so it may expand. For that purpose, I want to add aria-expanded attribute.

Scenario - user hovers the menu-item: aria-expanded=true, on blur aria-expanded=false. aria-expanded should be dynamic.

My snippet:

<li>
  {% assign menuExpanded = false %}
  <a class="ch-wp-menu-item-link" 
    href="{{item.value}}"
    onclick="return cityHiveMenuItemLinkClicked(event)"
    onmouseover={% assign menuExpanded = true %}
    onblur="{{menuExpanded = false}}"
    aria-expanded="{{menuExpanded}}">
    My menu item
  </a>
</li>

The issue I faced is that I can't just use the <script> tag, create a variable there, and then use it in the template itself.

What could be a solution here? Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回眸一遍 2025-01-30 19:24:43

添加以下代码行,它对我有用。
attr.aria-expanded =“ {{menuexpanded}}”

Add the following line of code instead, it worked for me.
attr.aria-expanded="{{menuExpanded}}"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文