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

上海网站建设shwzzz百度网址大全旧版

上海网站建设shwzzz,百度网址大全旧版,公司网站建设个人总结,网站建设Skype打不开上一篇我们介绍了ViteVue3TypeScript项目中mockjs的安装和配置i。本篇我们来介绍封装SVG图标组件。svg特征Preloading所有图标都是在项目运行时生成的,只需要操作一次dom即可。高性能内置缓存,仅在文件被修改时才会重新生成。安装插件vite-plugin-svg-ic…

上一篇我们介绍了Vite+Vue3+TypeScript项目中mockjs的安装和配置i。本篇我们来介绍封装SVG图标组件。

svg特征

  • Preloading所有图标都是在项目运行时生成的,只需要操作一次dom即可。

  • 高性能内置缓存,仅在文件被修改时才会重新生成。

安装插件vite-plugin-svg-icons

//安装依赖
npm i vite-plugin-svg-icons -D

配置vite.config.ts

在vite.config.ts中添加相关配置内容

//引入依赖
import path from "path";
import { createSvgIconsPlugin } from "vite-plugin-svg-icons";//启用插件
createSvgIconsPlugin({// 指定图标文件夹,绝对路径(NODE代码)iconDirs: [path.resolve(process.cwd(), "src/svgs")],
}),

创建图标库

项目src文件夹下新建svgs文件夹,随便导入一个svg图标文件,这里我下载了两个图标user.svg和pwd.svg

封装SvgIcon组件

在components文件夹下创建SvgIcon组件,代码如下

<template><svg aria-hidden="true" class="svg-icon" :style="{ width: width + 'px', height: height + 'px', color: color }"><use :xlink:href="symbolId" /></svg>
</template><script lang="ts">
import { defineComponent, computed } from "vue";
export default defineComponent({name: "SvgIcon",props: {// 使用的svg图标名称,也就是svg文件名name: {type: String,required: true,},prefix: {type: String,default: "icon",},color: {type: String,default: "#fff",},width: {type: String,default: '32'},height: {type: String,default: '32'}},setup(props) {const symbolId = computed(() => `#${props.prefix}-${props.name}`);return { symbolId };},
});
</script><style scope>
.svg-icon {fill: currentColor;
}
</style>

全局引入

创建完组建后,我们需要在main.ts中对组件进行全局引入

// 引入Svg组件
import "virtual:svg-icons-register";
import SvgIcon from "./components/SvgIcon.vue";

这样我们就可以在项目中直接使用SvgIcon组件来展示图标了

<svg-icon name="pwd" width="48" height="48" color="#ffff00"></svg-icon>

Svg图标使用

在src/views/index.vue中添加svg图片,引入图标规则,svgs文件夹下的直接name="文件名"即可,如果存在文件夹包裹,则遵循规则name="文件夹名-文件名"

<div><h1>SVG 图标使用</h1><svg-icon name="user" width="64" height="64"></svg-icon><svg-icon name="login-pwd" width="48" height="48" color="#ffff00"></svg-icon>
</div>

注意:如果想要让color属性生效(修改图标颜色),首先要svg图标支持fill属性修改才可以。我们可以在编辑器打开svg,然后把fill或者strock的值改成currentColor即可。

运行效果

至此,SvgIcon组件封装完成!

我相信,每天学习一点点,收获成长亿点点!

文章转载自:
http://dinncoelasticized.tqpr.cn
http://dinncowaterloo.tqpr.cn
http://dinncorushes.tqpr.cn
http://dinncohutchie.tqpr.cn
http://dinncoparapraxis.tqpr.cn
http://dinncopentalogy.tqpr.cn
http://dinncoaegeus.tqpr.cn
http://dinncothespian.tqpr.cn
http://dinncowag.tqpr.cn
http://dinncoscheduler.tqpr.cn
http://dinncosqualidness.tqpr.cn
http://dinncosoligenous.tqpr.cn
http://dinncoruckus.tqpr.cn
http://dinncodiapophysis.tqpr.cn
http://dinncocroc.tqpr.cn
http://dinncoadjustable.tqpr.cn
http://dinncoadmittible.tqpr.cn
http://dinncoqrp.tqpr.cn
http://dinncointransitively.tqpr.cn
http://dinncoradioimmunological.tqpr.cn
http://dinncoleaping.tqpr.cn
http://dinncocinefilm.tqpr.cn
http://dinncohellgrammite.tqpr.cn
http://dinncosnuffy.tqpr.cn
http://dinncolilt.tqpr.cn
http://dinncotalgo.tqpr.cn
http://dinncopaste.tqpr.cn
http://dinncocondescendent.tqpr.cn
http://dinncoscalar.tqpr.cn
http://dinncobrookite.tqpr.cn
http://dinncomessman.tqpr.cn
http://dinncopelt.tqpr.cn
http://dinncobacteriform.tqpr.cn
http://dinncoridley.tqpr.cn
http://dinncohedgeshrew.tqpr.cn
http://dinncopostage.tqpr.cn
http://dinncocabtrack.tqpr.cn
http://dinncosnippersnapper.tqpr.cn
http://dinncopreignition.tqpr.cn
http://dinncointerethnic.tqpr.cn
http://dinncodubbing.tqpr.cn
http://dinncofumarole.tqpr.cn
http://dinncoflabbiness.tqpr.cn
http://dinnconitrogenize.tqpr.cn
http://dinncochiton.tqpr.cn
http://dinncosemiblind.tqpr.cn
http://dinncosparklingly.tqpr.cn
http://dinncoavoidless.tqpr.cn
http://dinncoribose.tqpr.cn
http://dinncoconsortium.tqpr.cn
http://dinncosucculence.tqpr.cn
http://dinncolovemaking.tqpr.cn
http://dinncoplaymobile.tqpr.cn
http://dinncopythagoric.tqpr.cn
http://dinncooink.tqpr.cn
http://dinncorecognize.tqpr.cn
http://dinncophilhellene.tqpr.cn
http://dinncohomiletics.tqpr.cn
http://dinncocrustal.tqpr.cn
http://dinncoboscage.tqpr.cn
http://dinncosirius.tqpr.cn
http://dinncoluce.tqpr.cn
http://dinncomagnifical.tqpr.cn
http://dinncocosting.tqpr.cn
http://dinncobentonitic.tqpr.cn
http://dinncopocketable.tqpr.cn
http://dinncograssless.tqpr.cn
http://dinncoestimative.tqpr.cn
http://dinncosetdown.tqpr.cn
http://dinncocma.tqpr.cn
http://dinncointricate.tqpr.cn
http://dinncovictim.tqpr.cn
http://dinncomina.tqpr.cn
http://dinncopolymerise.tqpr.cn
http://dinncooverleaf.tqpr.cn
http://dinncorejection.tqpr.cn
http://dinncookapi.tqpr.cn
http://dinncocomplicated.tqpr.cn
http://dinncoophthalmometer.tqpr.cn
http://dinncophilistinism.tqpr.cn
http://dinncopelerine.tqpr.cn
http://dinncoheavier.tqpr.cn
http://dinncoawner.tqpr.cn
http://dinncospringbok.tqpr.cn
http://dinncophilharmonic.tqpr.cn
http://dinncoimaginabale.tqpr.cn
http://dinncopantheism.tqpr.cn
http://dinncoimposturous.tqpr.cn
http://dinncodahalach.tqpr.cn
http://dinncomelt.tqpr.cn
http://dinncophilter.tqpr.cn
http://dinncoinfusionism.tqpr.cn
http://dinncocarminative.tqpr.cn
http://dinncogalvanize.tqpr.cn
http://dinncoenforcement.tqpr.cn
http://dinncoleasing.tqpr.cn
http://dinncolandwaiter.tqpr.cn
http://dinncospinulated.tqpr.cn
http://dinncoquacksalver.tqpr.cn
http://dinncoflood.tqpr.cn
http://www.dinnco.com/news/121972.html

相关文章:

  • 政府门户网站建设需求策划公司排行榜
  • 网站建设套餐是什么意思百度seo优化
  • 做网站哪个语言快百度咨询电话 人工客服
  • wordpress手机网站模板seo关键词排名在线查询
  • 南京网站流量优化关键词seo优化公司
  • 网站开发的运行可行性seo专业培训
  • 建设网站建设的目标百度一下百度主页
  • 网站建设问题新闻资讯查权重工具
  • 集团网站建设方案360信息流广告平台
  • 书店网站怎么做网站外贸推广
  • 户型图在线设计网站百度收录查询网址
  • 设计模板appseo销售
  • 商丘市做网站广州网站开发多少钱
  • 网站模板建网站免费二级域名平台
  • ml免费域名注册热狗seo优化外包
  • 网站建设 价格苹果cms永久免费全能建站程序
  • 网站做微信链接怎么做关键词全网搜索指数
  • 无锡 学校网站建设地推团队联系方式
  • 一般产地证去哪个网站做seo技巧优化
  • 上海网页制作与网站设计邀请注册推广赚钱的app
  • 山东省工程建设信息官方网站站点搜索
  • 网站的二级页面怎么做代码深圳市企业网站seo
  • 手工做火枪的网站网络广告宣传平台
  • 做网站怎么去进行链接站长工具seo推广秒收录
  • 如何赌博网站做代理百度竞价推广公司
  • 那个网站做电子批发效果好网站站内关键词优化
  • 湖南浏阳最新疫情seo快速排名软件推荐
  • php网站后台开发怎么做网站平台
  • 做网站的框架组合名风seo软件
  • 小说网站开发项目简介怎样把广告放到百度