Browse Source

fix: icon async url bug

richard1015 5 years ago
parent
commit
897dbf60b5
1 changed files with 15 additions and 15 deletions
  1. 15 15
      src/packages/icon/index.vue

+ 15 - 15
src/packages/icon/index.vue

@@ -14,34 +14,34 @@ export default create({
   emits: ['click'],
   emits: ['click'],
 
 
   setup(props, { emit, slots }) {
   setup(props, { emit, slots }) {
-    const { name, size, classPrefix, color, tag } = toRefs(props);
-
     const handleClick = (event: Event) => {
     const handleClick = (event: Event) => {
       emit('click', event);
       emit('click', event);
     };
     };
 
 
-    const isImage = computed(() => {
-      return name.value ? name.value.indexOf('/') !== -1 : false;
-    }).value;
+    const isImage = () => {
+      return props.name ? props.name.indexOf('/') !== -1 : false;
+    };
 
 
-    return () =>
-      h(
-        isImage ? 'img' : tag.value,
+    return () => {
+      const _isImage = isImage();
+      return h(
+        _isImage ? 'img' : props.tag,
         {
         {
-          class: isImage
+          class: _isImage
             ? `${componentName}__img`
             ? `${componentName}__img`
-            : `${classPrefix.value} ${componentName}-${name.value}`,
+            : `${props.classPrefix} ${componentName}-${props.name}`,
           style: {
           style: {
-            color: color.value,
-            fontSize: size.value,
-            width: isImage ? size.value : '',
-            height: isImage ? size.value : ''
+            color: props.color,
+            fontSize: props.size,
+            width: _isImage ? props.size : '',
+            height: _isImage ? props.size : ''
           },
           },
           onClick: handleClick,
           onClick: handleClick,
-          src: isImage ? name.value : ''
+          src: _isImage ? props.name : ''
         },
         },
         slots.default?.()
         slots.default?.()
       );
       );
+    };
   }
   }
 });
 });
 </script>
 </script>