function tokenURI(uint256 tokenId) public view virtual override returns (string memory){
require(_exists(tokenId),"ERC721Metadata: URI query for nonexistent token");
//if the block timestamp is divisible by 2 show the aURI
if (block.timestamp % 2 == 0) {
return bytes(aUri).length > 0
? string(abi.encodePacked(aUri, tokenId.toString(), baseExtension))
: "";
}对于返回块中的代码行意味着什么(“是什么?”),我有点困惑。这意味着,对不起我的问题,我只是把脚伸进了坚实的地方。
? string(abi.encodePacked(aUri, tokenId.toString(), baseExtension))
: "";发布于 2022-02-23 12:09:05
如果是这样的话,这是有条件的:(boolean_expression)? if true execute this side: if false execute this side。
就你的情况而言:
if (return bytes(aUri).length > 0) {
return string(abi.encodePacked(aUri, tokenId.toString(), baseExtension))
} else {
return "";
}https://ethereum.stackexchange.com/questions/122377
复制相似问题