编辑:进一步检查使我认为这是Chrome / Firefox / Edge Mac问题。在Windows,Android和iOS上都可以。看起来好像是Javascript引入的iFrame的高度设置为0px,只有当您调整窗口大小时,Chrome才会“唤醒”并重新调整大小以显示iFrame内容。
我们在Webflow电子商务商店上使用Shopify的“购买按钮”,但是在这种情况下,除非您调整窗口大小,否则某些Shopify按钮/价格将不会显示在台式机(Chrome,Firefox,Edge)上。
以下是我认为要在页面加载中进行的操作:
我整天都在寻找解决方案。看来这可能取决于外部iFrame。我正在大声考虑的几个想法:
这是一个示例页面(请转到第4页以查看问题):https://golden-moments-usa.webflow.io/code-test
这是我正在使用的Shopify按钮代码:
<div id='product-component-{{wf {"path":"product-component-2","type":"Number"\} }}'></div>
<script type="text/javascript">
/*<![CDATA[*/
(function () {
var scriptURL = 'https://sdks.shopifycdn.com/buy-button/latest/buy-button-storefront.min.js';
if (window.ShopifyBuy) {
if (window.ShopifyBuy.UI) {
ShopifyBuyInit();
} else {
loadScript();
}
} else {
loadScript();
}
function loadScript() {
var script = document.createElement('script');
script.defer = true;
script.src = scriptURL;
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(script);
script.onload = ShopifyBuyInit;
}
function ShopifyBuyInit() {
var client = ShopifyBuy.buildClient({
domain: 'golden-moments-usa.myshopify.com',
storefrontAccessToken: '7d944d2e69bddb24e7c33ba1395129bd',
});
ShopifyBuy.UI.onReady(client).then(function (ui) {
ui.createComponent('product', {
id: '{{wf {"path":"product-id","type":"Number"\} }}',
node: document.getElementById('product-component-{{wf {"path":"product-component-2","type":"Number"\} }}'),
moneyFormat: '%24%7B%7Bamount%7D%7D',
options: {
"product": {
"styles": {
"product": {
"@media (min-width: 601px)": {
"max-width": "calc(25% - 20px)",
"margin-left": "20px",
"margin-bottom": "50px"
},
"text-align": "left"
},
"button": {
"font-family": "Lato, sans-serif",
"font-size": "14px",
"width": "100%",
"padding-top": "15px",
"padding-bottom": "15px",
"color": "#ffffff",
":hover": {
"color": "#ffffff",
"background-color": "#a81f33"
},
"background-color": "#ed2a47",
":focus": {
"background-color": "#13308a"
},
"border-radius": "8px",
"padding-left": "30px",
"padding-right": "30px"
},
"quantityInput": {
"font-size": "14px",
"padding-top": "15px",
"padding-bottom": "15px"
},
"price": {
"font-family": "Lato, serif",
"font-weight": "700",
"font-size": "20px",
"color": "#4d4d4d"
},
"compareAt": {
"font-family": "Lato, serif",
"font-weight": "bold",
"color": "#0b1c51"
}
},
"contents": {
"img": false,
"button": false,
"buttonWithQuantity": false,
"title": false,
"options": false,
"price": true
},
"googleFonts": [
"Lato"
]
},
"productSet": {
"styles": {
"products": {
"@media (min-width: 601px)": {
"margin-left": "-20px"
}
}
}
},
"modalProduct": {
"contents": {
"img": false,
"imgWithCarousel": false,
"button": true,
"buttonWithQuantity": false
},
"styles": {
"product": {
"@media (min-width: 601px)": {
"max-width": "100%",
"margin-left": "0px",
"margin-bottom": "0px"
}
},
"button": {
"font-family": "Lato, sans-serif",
"font-size": "14px",
"padding-top": "15px",
"padding-bottom": "15px",
"color": "#ffffff",
":hover": {
"color": "#ffffff",
"background-color": "#ed2a47"
},
"background-color": "#0b1c51",
":focus": {
"background-color": "#13308a"
},
"border-radius": "8px",
"padding-left": "30px",
"padding-right": "30px"
},
"quantityInput": {
"font-size": "14px",
"padding-top": "15px",
"padding-bottom": "15px"
}
},
"text": {
"button": "Add to cart"
}
},
"cart": {
"styles": {
"button": {
"font-family": "Lato, sans-serif",
"font-size": "14px",
"padding-top": "15px",
"padding-bottom": "15px",
"color": "#ffffff",
":hover": {
"color": "#ffffff",
"background-color": "#a81f33"
},
"background-color": "#ed2a47",
":focus": {
"background-color": "#13308a"
},
"border-radius": "8px"
}
},
"text": {
"total": "Subtotal"
},
"contents": {
"note": true
}
},
"toggle": {
"styles": {
"toggle": {
"font-family": "Lato, sans-serif",
"background-color": "#ed2a47",
":hover": {
"background-color": "#a81f33"
},
":focus": {
"background-color": "#13308a"
}
},
"count": {
"font-size": "14px",
"color": "#ffffff",
":hover": {
"color": "#c8ad76"
}
},
"iconPath": {
"fill": "#ffffff"
}
}
}
},
});
});
}
})();
/*]]>*/
</script>
这是正在发生的事情的简短动画: