EventBrite的弹出窗口小部件与React / JSX / GatsbyJs不兼容。寻找有关如何在Gatsby网站上适当实施此操作的帮助。如果您之前已经做过,那您做了什么?这是他们提供的代码:
<button id="example-widget-trigger" type="button">Buy Tickets</button>
<script src="https://www.eventbrite.com/static/widgets/eb_widgets.js"></script>
<script type="text/javascript">
var exampleCallback = function() {
console.log("Order complete!");
};
window.EBWidgets.createWidget({
widgetType: "checkout",
eventId: "52766401728",
modal: true,
modalTriggerElementId: "example-widget-trigger",
onOrderComplete: exampleCallback
});
</script>
答案 0 :(得分:1)
在终端的gatsby项目的根目录中的第一个运行命令cp .cache/default-html.js src/html.js
它将可以访问html.js文件。您可以在此处放置所需的代码,如下所示:
<script src="https://www.eventbrite.com/static/widgets/eb_widgets.js"></script>
<script
dangerouslySetInnerHTML={{
__html: `
var exampleCallback = function() {
console.log("Order complete!");
};
window.EBWidgets.createWidget({
widgetType: "checkout",
eventId: "52766401728",
modal: true,
modalTriggerElementId: "example-widget-trigger",
onOrderComplete: exampleCallback
});
`
}}
/>