根据 3.x 文档,将
data-config-add-product-behavior="none"
添加到 div#snipcart
元素对我来说不起作用,每次我将商品添加到购物车时,购物车仍然会出现。
不知道该做什么,其他一切对我来说都很好......
我知道你现在可能已经找到了解决方案,但对于任何正在为此苦苦挣扎的人 - 你需要将此行添加到可能位于 _document.js 中的侧边栏元素中。
祝你好运:)
它应该看起来像这样:
import { Html, Head, Main, NextScript } from "next/document";
export default function Document() {
return (
<Html>
<Head>
<link rel="preconnect" href="https://app.snipcart.com" />
<link rel="preconnect" href="https://cdn.snipcart.com" />
<link
rel="stylesheet"
href="https://cdn.snipcart.com/themes/v3.3.1/default/snipcart.css"
/>
</Head>
<body>
<Main />
<NextScript />
<script src="https://cdn.snipcart.com/themes/v3.2.0/default/snipcart.js"></script>
<div
hidden
id="snipcart"
data-api-key="YOURKEY"
data-config-modal-style="side"
data-config-add-product-behavior=""
></div>
</body>
</Html>
);
}