浏览代码

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

杨小璐 5 年之前
父节点
当前提交
4546fb6d70
共有 1 个文件被更改,包括 13 次插入4 次删除
  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!');
       }
+      
     }
   }
 };