File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change 11<template >
2- <svg :class =" svgClass" aria-hidden =" true" v-on =" $listeners" >
2+ <div v-if =" isExternal" :style =" styleExternalIcon" class =" svg-external-icon svg-icon" v-on =" $listeners" />
3+ <svg v-else :class =" svgClass" aria-hidden =" true" v-on =" $listeners" >
34 <use :xlink:href =" iconName" />
45 </svg >
56</template >
67
78<script >
9+ // doc: https://panjiachen.github.io/vue-element-admin-site/feature/component/svg-icon.html#usage
10+ import { isExternal } from ' @/utils/validate'
11+
812export default {
913 name: ' SvgIcon' ,
1014 props: {
@@ -18,6 +22,9 @@ export default {
1822 }
1923 },
2024 computed: {
25+ isExternal () {
26+ return isExternal (this .iconClass )
27+ },
2128 iconName () {
2229 return ` #icon-${ this .iconClass } `
2330 },
@@ -27,6 +34,12 @@ export default {
2734 } else {
2835 return ' svg-icon'
2936 }
37+ },
38+ styleExternalIcon () {
39+ return {
40+ mask: ` url(${ this .iconClass } ) no-repeat 50% 50%` ,
41+ ' -webkit-mask' : ` url(${ this .iconClass } ) no-repeat 50% 50%`
42+ }
3043 }
3144 }
3245}
@@ -40,4 +53,10 @@ export default {
4053 fill : currentColor ;
4154 overflow : hidden ;
4255}
56+
57+ .svg-external-icon {
58+ background-color : currentColor ;
59+ mask-size : cover !important ;
60+ display : inline-block ;
61+ }
4362 </style >
You can’t perform that action at this time.
0 commit comments