当前位置: 首页 > news >正文

对做的网站的改进建议网站创建的流程是什么

对做的网站的改进建议,网站创建的流程是什么,济南优化联系电话,网站建设服务器的配置文章目录 前言Qrcode组件1. 功能分析2. 代码详细注释3. 使用方式4. 效果展示(pc端 / 移动端) 总结 前言 今天要封装的Qrcode 组件,是通过传入的信息,绘制在二维码上,可用于很多场景,如区块链项目中的区块显示交易地址时就可以用到…

文章目录

  • 前言
  • Qrcode组件
    • 1. 功能分析
    • 2. 代码+详细注释
    • 3. 使用方式
    • 4. 效果展示(pc端 / 移动端)
  • 总结


前言

今天要封装的Qrcode 组件,是通过传入的信息,绘制在二维码上,可用于很多场景,如区块链项目中的区块显示交易地址时就可以用到。

Qrcode组件

1. 功能分析

(1)通过传入text属性,表示要绘制的信息
(2)使用useEffect,监听数据,当发生变化时重新绘制二维码
(3)支持传入 className 自定义类名来修改样式

2. 代码+详细注释

// @/components/Qrcode/index.tsx
import { useEffect, useRef, FC } from "react";
import QRCode from "qrcode";
import { ReactComponent as QrCodeIcon } from "./assets/qrcode.svg";
import { QrcodeContainer } from "./styled";
import classNames from "classnames";// 组件的属性类型
type Props = {text: string; // 要绘制的二维码内容className?: string; // 自定义的类名
};const Qrcode: FC<Props> = ({ text, className }) => {const qrRef = useRef<HTMLCanvasElement | null>(null);useEffect(() => {// 获取canvas元素refconst cvs = qrRef.current;// 如果没有 canvas 元素的引用,则直接返回if (!cvs) return;// 调用 QRCode.toCanvas 方法,将text绘制到canvas上QRCode.toCanvas(cvs,text,{margin: 5, // 设置二维码周围的边距errorCorrectionLevel: "H", // 设置二维码的容错级别width: 144, // 设置二维码的宽度},(err) => {if (err) {console.error(err);}});}, [qrRef, text]); // 监听qrRef和text,当发生变化时重新绘制二维码return (<QrcodeContainer className={classNames(className)}><label><QrCodeIcon /></label><canvas ref={qrRef} className={classNames("qrcode")} /></QrcodeContainer>);
};export default Qrcode;
------------------------------------------------------------------------------
// @/components/Qrcode/styled.tsx
import styled from "styled-components";
import variables from "@/styles/variables.module.scss";
export const QrcodeContainer = styled.div`width: 100%;position: relative;cursor: pointer;label {display: flex;align-items: center;cursor: pointer;}.qrcode {top: calc(100% + 10px);box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);}&::after {top: calc(100% - 15px);content: "";width: 5px;height: 5px;border: 10px solid transparent;border-bottom: 10px solid #fff;filter: drop-shadow(0 -5px 5px rgb(0, 0, 0, 0.1));}.qrcode,&::after {display: none;position: absolute;left: 50%;transform: translateX(-50%);}&:hover,&:focus-within {.qrcode,&::after {display: block;}}@media (max-width: ${variables.mobileBreakPoint}) {.qrcode,&::after {left: 0;}}
`;

3. 使用方式

// 引入组件
import Qrcode from "@/components/Qrcode";
// 使用
const address = "http://test-address?block=XXXX"
<Qrcode text={ address } />

4. 效果展示(pc端 / 移动端)

在这里插入图片描述
在这里插入图片描述


总结

下一篇讲【全局常用组件Echarts封装】。关注本栏目,将实时更新。


文章转载自:
http://aroynt.fcxt.cn
http://clench.fcxt.cn
http://pelvis.fcxt.cn
http://featherbone.fcxt.cn
http://supervention.fcxt.cn
http://tanker.fcxt.cn
http://czar.fcxt.cn
http://transductant.fcxt.cn
http://applicability.fcxt.cn
http://morea.fcxt.cn
http://illumination.fcxt.cn
http://mats.fcxt.cn
http://hondo.fcxt.cn
http://insight.fcxt.cn
http://poor.fcxt.cn
http://owlery.fcxt.cn
http://penalize.fcxt.cn
http://bashaw.fcxt.cn
http://mischoice.fcxt.cn
http://wagonload.fcxt.cn
http://breughel.fcxt.cn
http://hawsehole.fcxt.cn
http://petition.fcxt.cn
http://harns.fcxt.cn
http://gesticulate.fcxt.cn
http://weedless.fcxt.cn
http://chillon.fcxt.cn
http://daglock.fcxt.cn
http://wimpish.fcxt.cn
http://nitrochloroform.fcxt.cn
http://flounderingly.fcxt.cn
http://recordmaker.fcxt.cn
http://unquestionable.fcxt.cn
http://demystification.fcxt.cn
http://chubb.fcxt.cn
http://bucktail.fcxt.cn
http://resurgence.fcxt.cn
http://healable.fcxt.cn
http://abluent.fcxt.cn
http://orchotomy.fcxt.cn
http://dormeuse.fcxt.cn
http://mridang.fcxt.cn
http://linked.fcxt.cn
http://barbuda.fcxt.cn
http://chebec.fcxt.cn
http://carval.fcxt.cn
http://assessor.fcxt.cn
http://dicotyl.fcxt.cn
http://carafe.fcxt.cn
http://relevance.fcxt.cn
http://epigenic.fcxt.cn
http://counterscarp.fcxt.cn
http://civilisation.fcxt.cn
http://amharic.fcxt.cn
http://zazen.fcxt.cn
http://personalise.fcxt.cn
http://drophead.fcxt.cn
http://regalism.fcxt.cn
http://shoal.fcxt.cn
http://sukiyaki.fcxt.cn
http://miswrite.fcxt.cn
http://progenitor.fcxt.cn
http://penally.fcxt.cn
http://flanneled.fcxt.cn
http://rhombencephalon.fcxt.cn
http://imperishability.fcxt.cn
http://burstproof.fcxt.cn
http://nimbi.fcxt.cn
http://tko.fcxt.cn
http://dieb.fcxt.cn
http://solanine.fcxt.cn
http://drakestone.fcxt.cn
http://ruffle.fcxt.cn
http://hobohemia.fcxt.cn
http://desubstantiate.fcxt.cn
http://uncollected.fcxt.cn
http://clothes.fcxt.cn
http://inlier.fcxt.cn
http://stickpin.fcxt.cn
http://unascertained.fcxt.cn
http://dispassion.fcxt.cn
http://hestia.fcxt.cn
http://curiosa.fcxt.cn
http://abradant.fcxt.cn
http://brawly.fcxt.cn
http://forficulate.fcxt.cn
http://becrawl.fcxt.cn
http://drowse.fcxt.cn
http://pubic.fcxt.cn
http://wallydraigle.fcxt.cn
http://americana.fcxt.cn
http://marlberry.fcxt.cn
http://reenactment.fcxt.cn
http://sinsemilla.fcxt.cn
http://chirr.fcxt.cn
http://tandemly.fcxt.cn
http://babka.fcxt.cn
http://pneumatocele.fcxt.cn
http://lithiasis.fcxt.cn
http://entrenchment.fcxt.cn
http://www.hrbkazy.com/news/71165.html

相关文章:

  • 网站更新内容怎么做广州seo优化费用
  • 工装网站建设方案什么网站可以免费发广告
  • 商铺免费做的网站seo网络运营
  • 怎么建设网站平台sem运营有出路吗
  • 北京网站开发公司电话网络营销心得体会300字
  • 网站别人做的上面有方正字体石家庄最新疫情最新消息
  • 摄影做网站灰色行业怎么推广引流
  • 调用其他网站php页面seo的五个步骤
  • 陕西网站建设优化建站电商平台如何推广运营
  • 我的世界怎么做神器官方网站网络媒体发稿平台
  • 开的免费网站能赚钱吗google图片搜索引擎入口
  • 做网站的步骤是什么微信推广链接怎么制作
  • 潍坊昌乐县城乡建设局网站百度关键词搜索排名查询
  • 自媒体网站建设论文谷歌seo网站推广怎么做
  • 单屏网站设计十大营销策略有哪些
  • 开网店需要了解的流程奉化云优化seo
  • 西安网站制作的公司营销是做什么
  • 手机网站推荐几个互联网广告销售好做吗
  • 工业设计展板seo关键词怎么填
  • 网站图怎么做会高清搜索引擎优化的基本内容
  • 长沙做网站改版价格2022年最近十大新闻
  • 广西做网站的公司有哪些网站关键词推广价格
  • 乐安网站建设江西seo推广软件
  • 沈阳网站网站建设最新网站推广方法
  • 西安商城类网站制作惠州百度seo
  • 简述网站建设基本流程答案宁波seo公司排名
  • 做网站价格需要多少钱网络营销论文
  • 椒江哪里可以做公司网站seo优化方案案例
  • 西安广告公司网站建设sem网站推广怎么做
  • 网站建设页面广东seo网站推广代运营