Browse Source

fix: 优化icon组件内部添加图标的方法

杨小璐 5 years ago
parent
commit
4546fb6d70
1 changed files with 13 additions and 4 deletions
  1. 13 4
      src/packages/icon/icon.vue

+ 13 - 4
src/packages/icon/icon.vue

@@ -61,11 +61,20 @@ export default {
       this.icon = this.url;
       this.type = 'self';
     } else {
-      if (types.indexOf(this.type) === -1) {
-        console.error('nut-icon组件type值(' + this.type + ')有误,无此icon!');
-      } else {
-        this.icon = require('../../assets/svg/' + this.type + '.svg');
+
+      // if (types.indexOf(this.type) === -1) {
+      //   console.error('nut-icon组件type值(' + this.type + ')有误,无此icon!');
+      // } else {
+      //   this.icon = require('../../assets/svg/' + this.type + '.svg');
+      // }
+
+      try {
+          this.icon = require('../../assets/svg/' + this.type + '.svg')
+      }
+      catch(err) {
+          console.error('nut-icon组件type值(' + this.type + ')有误,无此icon!');
       }
+      
     }
   }
 };