Gathering detailed insights and metrics for vite-plugin-svg-qk-icon
Gathering detailed insights and metrics for vite-plugin-svg-qk-icon
npm install vite-plugin-svg-qk-icon
Typescript
Module System
Node Version
NPM Version
69.1
Supply Chain
95.2
Quality
74.1
Maintenance
100
Vulnerability
100
License
Total Downloads
589
Last Day
1
Last Week
3
Last Month
11
Last Year
135
Minified
Minified + Gzipped
Latest Version
1.0.4
Package Id
vite-plugin-svg-qk-icon@1.0.4
Unpacked Size
12.17 kB
Size
4.69 kB
File Count
5
NPM Version
7.10.0
Node Version
16.0.0
Cumulative downloads
Total Downloads
Last day
-50%
1
Compared to previous day
Last week
-57.1%
3
Compared to previous week
Last month
-21.4%
11
Compared to previous month
Last year
2.3%
135
Compared to previous year
4
在vite中使用svg文件时更方便。支持热更新。 注册名称,主要为了解决使用qiankun时多应用使用svg,图标不显示的问题
1npm i vite-plugin-svg-qk-icon -D
1import path from 'path'; 2import {vitePluginSvg} from "vite-plugin-svg-qk-icon"; 3import {defineConfig} from 'vite'; 4// https://vitejs.dev/config/ 5export default defineConfig({ 6 plugins: [ 7 // ...other plugin 8 9 vitePluginSvg({ 10 // 必要的。必须是绝对路径组成的数组。 11 iconDirs: [ 12 path.resolve(__dirname, 'src/assets/icons'), 13 path.resolve(__dirname, 'src/assets/other/icons'), 14 ], 15 16 //注册名称,主要为了解决使用qiankun时多应用使用svg,图标不显示的问题 17 registerModuleName:'virtual:vite-plugin-svg-qrcode-register', 18 // 必要的。入口script 19 main: path.resolve(__dirname, 'src/main.js'), 20 symbolIdFormat: 'icon-[name]' 21 }), 22 ] 23}); 24
1<template> 2 <svg class="SvgIcon" aria-hidden="true"><use :xlink:href="symbolId" /></svg> 3</template> 4<script> 5import { defineComponent, computed } from 'vue'; 6export default defineComponent({ 7 name: 'SvgIcon', 8 props: { 9 name: { 10 type: String, 11 required: true, 12 } 13 }, 14 setup(props) { 15 const symbolId = computed(() => `#icon-${props.name}`) 16 return { symbolId } 17 } 18}) 19</script> 20<style scoped> 21 .SvgIcon { 22 font-size: inherit; 23 fill: currentColor; 24 width: 1em; 25 height: 1em; 26 text-indent: 0; 27 } 28</style>
1<template> 2 <div> 3 <SvgIcon name="ban"></SvgIcon> 4 </div> 5</template> 6<script> 7import { defineComponent } from 'vue'; 8import SvgIcon from './components/SvgIcon.vue'; 9export default defineComponent({ 10 components: { SvgIcon }, 11}) 12</script> 13<style scoped> 14 .SvgIcon { 15 font-size: 30px; 16 color: blue; 17 } 18</style>
No vulnerabilities found.
No security vulnerabilities found.