Qwik JS - 动态类在服务器上加载,但不会在客户端上重新渲染 <链接>单击

Qwik JS - Dynamic class loads on server, but doesn't re-render on client on <Link> click

提问人:Not Stupar 提问时间:10/23/2023 最后编辑:johanneslinkNot Stupar 更新时间:10/24/2023 访问量:22

问:

我做错了什么?

export const NavLink = component$<LinkProps>((props) => {
  const location = useLocation();
  const pathname = location.url.pathname;

  return (
    <>
      <li>
        <Link
          href={props.href}
          is-active={pathname == props.href ? "1":"0"}
          class={[
            "block rounded py-2 pl-3 pr-4 transition-[hover] hover:bg-gray-100 dark:border-gray-700 dark:text-white dark:hover:bg-gray-700 dark:hover:text-white lg:p-0 lg:hover:bg-transparent lg:hover:text-violet-700 lg:dark:hover:bg-transparent lg:dark:hover:text-blue-500",
            pathname == props.href ? "text-[red]" : "text-gray-900",
            {
            "bg-[blue]":pathname == props.href
            }
          ]}
        >
          <Slot />
        </Link>
      </li>
    </>
  );
});

在此处输入图像描述

我使用属性“is-acitve”进行了测试,它在浏览器中更新,但类不会改变,类仅在我刷新页面时才会改变。

qwik qwikjs

评论


答: 暂无答案