首页以卡片形式来展示区块链列表数据(Web3项目一实战之五)

我们已然在 Web3 分布式存储 IPFS(Web3项目一实战之四) 介绍了什么是IPFS,以及在本地电脑如何安装它。虽然在上一篇讲解了该怎么安装IPFS,也做了相应的配置,但在本地开发阶段,前端总是无法避免跨域这个远程请求api的”家常便饭的通病“。

很显然,对于出现跨域这类常见问题,您只要在搜索引擎敲上reactjs 跨域vue跨域nextjs 跨域等诸如此类关键字,不一会,搜索引擎为您罗列出了一大堆关于解决跨域的方案。

那么,在编写首页以卡片形式展示数据前,我们要在项目中配置跨域,以便可以在IPFS上存取文件。

配置跨域

文章已经写到了第五篇,想必您清楚了,本项目是使用create-next-app脚手架构建的项目,也就说,该项目是next.js项目了,但它也是react项目。

打开项目根目录下的next.config.js文件。加入如下图红框中的内容。

  • 18
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
好的,以下是一个简单的HTML时钟倒计时翻转卡片效果的示例代码: ```html <!DOCTYPE html> <html> <head> <title>时钟倒计时翻转卡片效果</title> <style> .container { display: flex; justify-content: center; align-items: center; height: 100vh; background-color: #f5f5f5; perspective: 1000px; } .card { position: relative; width: 200px; height: 200px; transform-style: preserve-3d; transition: transform 0.6s; } .front, .back { position: absolute; top: 0; left: 0; width: 100%; height: 100%; backface-visibility: hidden; box-shadow: 0 0 5px rgba(0, 0, 0, 0.2); border-radius: 5px; display: flex; justify-content: center; align-items: center; font-size: 3rem; font-weight: bold; color: #fff; } .front { background-color: #2196f3; transform: rotateY(0deg); } .back { background-color: #f44336; transform: rotateY(180deg); } </style> </head> <body> <div class="container"> <div class="card" id="card"> <div class="front"> <span id="countdown"></span> </div> <div class="back"> <span id="countdown"></span> </div> </div> </div> <script> // 倒计时时间(单位:秒) const countdownTime = 60; // 获取DOM元素 const card = document.getElementById('card'); const countdown = document.getElementById('countdown'); // 倒计时函数 function startCountdown() { let timeLeft = countdownTime; let timer = setInterval(() => { // 更新倒计时秒数 countdown.innerHTML = timeLeft; // 如果倒计时结束 if (timeLeft === 0) { // 清除定时器 clearInterval(timer); // 翻转卡片 card.classList.toggle('flipped'); } timeLeft--; }, 1000); } // 页面加载完毕后开始倒计时 window.onload = startCountdown; </script> </body> </html> ``` 这段代码使用了CSS的`transform`属性实现卡片翻转效果,同时使用了JavaScript实现了倒计时功能,当倒计时结束后会翻转卡片。你可以根据需要修改代码来适应自己的需求。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

甄齐才

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值