You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

36 lines
976 B

  1. /**
  2. * 根据主题type值,获取对应的图标
  3. * @param String type 主题名称,primary|info|error|warning|success
  4. * @param String fill 是否使用fill填充实体的图标
  5. */
  6. function type2icon(type = 'success', fill = false) {
  7. // 如果非预置值,默认为success
  8. if (['primary', 'info', 'error', 'warning', 'success'].indexOf(type) == -1) type = 'success';
  9. let iconName = '';
  10. // 目前(2019-12-12),info和primary使用同一个图标
  11. switch (type) {
  12. case 'primary':
  13. iconName = 'info-circle';
  14. break;
  15. case 'info':
  16. iconName = 'info-circle';
  17. break;
  18. case 'error':
  19. iconName = 'close-circle';
  20. break;
  21. case 'warning':
  22. iconName = 'error-circle';
  23. break;
  24. case 'success':
  25. iconName = 'checkmark-circle';
  26. break;
  27. default:
  28. iconName = 'checkmark-circle';
  29. }
  30. // 是否是实体类型,加上-fill,在icon组件库中,实体的类名是后面加-fill的
  31. if (fill) iconName += '-fill';
  32. return iconName;
  33. }
  34. export default type2icon