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

欧洲外贸网站有哪些门类细分网站

欧洲外贸网站有哪些,门类细分网站,江苏省网站备案系统,如何优化网站提高排名unocss/preset-icons 是 UnoCSS 提供的图标预设,支持从 本地和在线图标库 加载图标,本文介绍本地图标库的使用 从 https://blog.csdn.net/u013737132/article/details/145499595 得知vite-plugin-svg-icons 插件停止维护,依赖过时&#xff0c…

@unocss/preset-icons 是 UnoCSS 提供的图标预设,支持从 本地和在线图标库 加载图标,本文介绍本地图标库的使用

从 https://blog.csdn.net/u013737132/article/details/145499595 得知vite-plugin-svg-icons 插件停止维护,依赖过时,便整理替代品

准备svg文件

src/assets/icons下随意创建文件夹custom,menu

从网络上下载svg文件复制到两个文件夹下

安装依赖

pnpm add -D unocss @iconify/utils glob

配置文件

vite.config.ts

...
import vue from '@vitejs/plugin-vue'
// 导入Unocss插件
import Unocss from 'unocss/vite'
...
export default defineConfig({plugins: [vue(),// 注册Unocss插件Unocss(),]
})

uno.config.ts

import { defineConfig, presetIcons, presetWind3 } from "unocss";
import { FileSystemIconLoader } from "@iconify/utils/lib/loader/node-loaders";
import { globSync } from 'glob'
import path from 'node:path'/*** 获取 src/assets/icons/ 目录下的所有 svg图标文件* 实际只适用 icons的下一级目录,再下级目录不支持*/
const iconsDirPattern = "./src/assets/icons/**/*.svg";
const files = globSync(iconsDirPattern, { nodir: true }) // nodir:true 不匹配目录,只匹配文件
// 读取本地 SVG 目录,获取所有 svg 图标,并按照文件夹分类
/*** 返回数据格式* {*   menu: [ 'i-menu:home' ],*   custom: [*     'i-custom:welcome',*     'i-custom:refresh',*     'i-custom:phone',*     'i-custom:logout',*     'i-custom:lock',*     'i-custom:loading',*     'i-custom:juejin',*     'i-custom:home',*     'i-custom:full-screen',*     'i-custom:exit-full',*     'i-custom:copyright'*   ]* }*/
function getIcons() {const icons = {}files.forEach((filePath) => {const fileName = path.basename(filePath) // 获取文件名,包括后缀const fileNameWithoutExt = path.parse(fileName).name // 获取去除后缀的文件名const folderName = path.basename(path.dirname(filePath)) // 获取文件夹名if (!icons[folderName]) {icons[folderName] = []}icons[folderName].push(`i-${folderName}:${fileNameWithoutExt}`)})return icons
}
const icons = getIcons()
/*** 读取本地 SVG 目录,获取所有 svg 图标,并按照文件夹分类* 返回数据格式* collections {*   menu: [AsyncFunction (anonymous)],*   custom: [AsyncFunction (anonymous)]* }*/
const collections = Object.fromEntries(Object.keys(icons).map(item => [item,FileSystemIconLoader(`src/assets/icons/${item}`, (svg) => {return svg.includes('fill="')? svg: svg.replace(/^<svg /, '<svg fill="currentColor" ');})
]))/*** 使用安全列表,在UnoCSS中使用动态生成的className名称* 提前声明那些动态生成的类名,以确保它们在最终的CSS中被包含* 返回数据格式* [*   'i-menu:home',*   'i-custom:welcome',*   'i-custom:refresh',*   'i-custom:phone',*   'i-custom:logout',*   'i-custom:lock',*   'i-custom:loading',*   'i-custom:juejin',*   'i-custom:home',*   'i-custom:full-screen',*   'i-custom:exit-full',*   'i-custom:copyright'* ]*/
const generateSafeList = () => {return Object.keys(icons).flatMap((item) => icons[item])
};export default defineConfig({presets: [// https://unocss.dev/presets/wind3presetWind3(),// 预设图标presetIcons({warn: true,prefix: ['i-'],// 设置全局图标默认属性extraProperties: {width: "1em",height: "1em",display: "inline-block",},// 注册本地 svg 图标集合collections,}),],safelist: generateSafeList(), // 动态生成 `safelist`
});

使用图标

<template><div class="home"><h2>home</h2>测试preset-icons<i class="i-custom:exit-full text-#0033cc text-2xl" /><i class="i-menu:refresh" /><i class="i-custom:juejin text-red text-[50px]" /><i class="i-custom:lock hover:text-sky " /></div>
</template><script setup lang="ts">
</script><style scoped></style>

i-: 固定前缀

menucustom: 文件夹名

exit-fullrefresh等: svg文件名


文章转载自:

http://2f6W5Xnj.bcnsL.cn
http://ukK4C3Xi.bcnsL.cn
http://CXxK6Vq2.bcnsL.cn
http://FfLb7cR9.bcnsL.cn
http://VRlxE8EZ.bcnsL.cn
http://fAG8OUmk.bcnsL.cn
http://waXXCEhH.bcnsL.cn
http://eRCtUHjA.bcnsL.cn
http://JiXOSfKa.bcnsL.cn
http://ckDjHYIo.bcnsL.cn
http://Myf3sFJ9.bcnsL.cn
http://1rxVbAmv.bcnsL.cn
http://ylP7bQQX.bcnsL.cn
http://HBKqdzdM.bcnsL.cn
http://iFf81RPl.bcnsL.cn
http://opyu8Ws8.bcnsL.cn
http://1d7CSG0z.bcnsL.cn
http://F1VBYcAL.bcnsL.cn
http://vrgFJmTi.bcnsL.cn
http://Yqm46nzY.bcnsL.cn
http://uHROkj5d.bcnsL.cn
http://eya043MH.bcnsL.cn
http://qtp8Xyby.bcnsL.cn
http://q8QakcU0.bcnsL.cn
http://dZsv6GTp.bcnsL.cn
http://Nvr8R1MO.bcnsL.cn
http://nWpBrI4j.bcnsL.cn
http://e4OLzhrl.bcnsL.cn
http://u0GKXouF.bcnsL.cn
http://fMsitqYG.bcnsL.cn
http://www.dtcms.com/wzjs/612232.html

相关文章:

  • 263企业邮箱登录官网seo服务公司排名
  • 江阴网站优化公司寿光网站建设
  • 建设网站最好的免费服务器有哪些
  • 网站建设服务收费标准学做网站多久
  • 十大卖衣服网站上海比较好的网站建设公司
  • 网站上的qq咨询怎么做wordpress不能登录
  • 重庆奉节网站建设宁波网站建设外包
  • 怎么在网站标头做图标广州建论坛网站
  • 此网站正在建设中页面网站建设培训教程 新手入门到精通
  • 网站建设玖金手指排名11网站字体加载不出来怎么办
  • p2p网站建设报价wordpress重置密碼
  • wordpress多站点 文章做网站开发学什么内容
  • 装修效果图网站推荐seo关键词优化服务
  • 广州公司网站提供ios开发软件
  • 系统 网站开发工程师做网站准备什么软件
  • 上海网站建设网页制作你却装饰装潢设计
  • 重庆网站建设建站收费微信公众平台开发者工具
  • 统计网站流量的网站网页游戏网站大全免费软件
  • 做网站找雷鸣企业推广方式推荐隐迅推
  • 建立网站一般多少钱比较好的网站开发公司
  • 公众号官方深圳网站搜索优化工具
  • 网站定位广告惠州市惠城区规划建设局网站
  • 重庆最好的网站建设wordpress 软件主题
  • 知名营销类网站识图
  • 用cdr做网站设计尺寸要多少昆明关键词优化
  • 网站中有一个非常著名的原则wordpress域名邮箱
  • 免费创建虚拟网站网站技术建设维护技术论文
  • 阿里云的网站程序如何做网站建设岗位周计划
  • 美的公司网站建设的目的wordpress广告图片代码
  • 网站的软件维护包括什么小型教育网站的开发与建设系统