这是针对NFT薄荷Dapp。我的Web应用程序中有4个不同的NFTS铸造页面,并在Nextjs构建中,每个nfts应用程序都被铸造出来,我的按钮出现了一个按钮,上面显示“ Opensea上的视图”。
当您单击此按钮时,我希望它可以打开一个新标签,并将您发送到单个列表中的链接,看起来像:
“ testnets.opensea.io/assets/mumbai/0xB636C1A63C3B092A7C74304B1947B0162D08A1E4/0”。
0xb63 ...是合同地址, / /0是代币。我将代币保存在数据文件中,将其传递到我的应用程序的其他领域。但是我不知道如何将其纳入URL。
这是我到目前为止所拥有的:
const url =
"testnets.opensea.io/assets/mumbai/0xb636c1a63c3b092a7c74304b1947b0162d08a1e4/{props.id}";
window.open(url, "_blank");
};
但是它不起作用。对此的任何帮助都是感谢。这是我的回购中指向该行的链接:
This is for an NFT minting dAPP. I have 4 different NFTs minting pages in my web app built with nextjs, and after each one is minted I have a button appear that says "View on OpenSea".
When you click on this button, I'd like it so that it will open a new tab and send you to the individual listing to a link that looks like:
"testnets.opensea.io/assets/mumbai/0xb636c1a63c3b092a7c74304b1947b0162d08a1e4/0".
0xb63... being the contract address, and /0 being the tokenID. I have the tokenId saved in a data file, passing that prop into other areas of my app. But I can't figure out how to get it into a URL.
This is what I have so far:
const url =
"testnets.opensea.io/assets/mumbai/0xb636c1a63c3b092a7c74304b1947b0162d08a1e4/{props.id}";
window.open(url, "_blank");
};
But it doesn't work. Any help on this is appreciate. Here is a link to that line in my repo: https://github.com/redbrickmedia/rdbrck-nft/blob/0872e3bbd69ae12ff2b2d5532d5e0da0c78663fa/components/Buttons.js#L52
发布评论
评论(1)
刚刚尝试了您的代码并正常工作,但我的浏览器会自动阻止编程弹出窗口。我建议用
< a href =“ url” target =“ _ blank”>
替换按钮,使其看起来像您的填充顿。也许是因为您的道具没有插值,请尝试以下操作:
Just tried your code and works fine but my browser automatically blocks programmatic popups. I'd suggest to replace the button with an
<a href="url" target="_blank">
and make it look like your FilledButton.Maybe it's because your prop is not getting interpolated, try the following: