index.js 1007 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import _mergeJSXProps from "@vue/babel-helper-vue-jsx-merge-props";
  2. import { use } from '../utils';
  3. import { inherit } from '../utils/functional';
  4. import Info from '../info';
  5. import { isSrc } from '../utils/validate/src'; // Types
  6. var _use = use('icon'),
  7. sfc = _use[0];
  8. function Icon(h, props, slots, ctx) {
  9. var urlIcon = isSrc(props.name);
  10. return h(props.tag, _mergeJSXProps([{
  11. "class": [props.classPrefix, urlIcon ? 'van-icon--image' : props.classPrefix + "-" + props.name],
  12. "style": {
  13. color: props.color,
  14. fontSize: props.size
  15. }
  16. }, inherit(ctx, true)]), [slots["default"] && slots["default"](), urlIcon && h("img", {
  17. "attrs": {
  18. "src": props.name
  19. }
  20. }), h(Info, {
  21. "attrs": {
  22. "info": props.info
  23. }
  24. })]);
  25. }
  26. Icon.props = {
  27. name: String,
  28. size: String,
  29. color: String,
  30. info: [String, Number],
  31. tag: {
  32. type: String,
  33. "default": 'i'
  34. },
  35. classPrefix: {
  36. type: String,
  37. "default": 'van-icon'
  38. }
  39. };
  40. export default sfc(Icon);