u-icon.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. "use strict";
  2. const common_vendor = require("../../../../common/vendor.js");
  3. const _sfc_main = {
  4. name: "u-icon",
  5. data() {
  6. return {};
  7. },
  8. emits: ["click"],
  9. mixins: [common_vendor.mpMixin, common_vendor.mixin, common_vendor.props$2],
  10. computed: {
  11. uClasses() {
  12. let classes = [];
  13. classes.push(this.customPrefix + "-" + this.name);
  14. if (this.color && common_vendor.index.$u.config.type.includes(this.color))
  15. classes.push("u-icon__icon--" + this.color);
  16. return classes;
  17. },
  18. iconStyle() {
  19. let style = {};
  20. style = {
  21. fontSize: common_vendor.index.$u.addUnit(this.size),
  22. lineHeight: common_vendor.index.$u.addUnit(this.size),
  23. fontWeight: this.bold ? "bold" : "normal",
  24. // 某些特殊情况需要设置一个到顶部的距离,才能更好的垂直居中
  25. top: common_vendor.index.$u.addUnit(this.top)
  26. };
  27. if (this.color && !common_vendor.index.$u.config.type.includes(this.color))
  28. style.color = this.color;
  29. return style;
  30. },
  31. // 判断传入的name属性,是否图片路径,只要带有"/"均认为是图片形式
  32. isImg() {
  33. return this.name.indexOf("/") !== -1;
  34. },
  35. imgStyle() {
  36. let style = {};
  37. style.width = this.width ? common_vendor.index.$u.addUnit(this.width) : common_vendor.index.$u.addUnit(this.size);
  38. style.height = this.height ? common_vendor.index.$u.addUnit(this.height) : common_vendor.index.$u.addUnit(this.size);
  39. return style;
  40. },
  41. // 通过图标名,查找对应的图标
  42. icon() {
  43. return common_vendor.icons["uicon-" + this.name] || this.name;
  44. }
  45. },
  46. methods: {
  47. clickHandler(e) {
  48. this.$emit("click", this.index);
  49. this.stop && this.preventEvent(e);
  50. }
  51. }
  52. };
  53. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  54. return common_vendor.e({
  55. a: $options.isImg
  56. }, $options.isImg ? {
  57. b: _ctx.name,
  58. c: _ctx.imgMode,
  59. d: common_vendor.s($options.imgStyle),
  60. e: common_vendor.s(_ctx.$u.addStyle(_ctx.customStyle))
  61. } : {
  62. f: common_vendor.t($options.icon),
  63. g: common_vendor.n($options.uClasses),
  64. h: common_vendor.s($options.iconStyle),
  65. i: common_vendor.s(_ctx.$u.addStyle(_ctx.customStyle)),
  66. j: _ctx.hoverClass
  67. }, {
  68. k: _ctx.label !== ""
  69. }, _ctx.label !== "" ? {
  70. l: common_vendor.t(_ctx.label),
  71. m: _ctx.labelColor,
  72. n: _ctx.$u.addUnit(_ctx.labelSize),
  73. o: _ctx.labelPos == "right" ? _ctx.$u.addUnit(_ctx.space) : 0,
  74. p: _ctx.labelPos == "bottom" ? _ctx.$u.addUnit(_ctx.space) : 0,
  75. q: _ctx.labelPos == "left" ? _ctx.$u.addUnit(_ctx.space) : 0,
  76. r: _ctx.labelPos == "top" ? _ctx.$u.addUnit(_ctx.space) : 0
  77. } : {}, {
  78. s: common_vendor.o((...args) => $options.clickHandler && $options.clickHandler(...args)),
  79. t: common_vendor.n("u-icon--" + _ctx.labelPos)
  80. });
  81. }
  82. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-1c933a9a"], ["__file", "D:/project/赋强公证/notarization_applet/node_modules/uview-plus/components/u-icon/u-icon.vue"]]);
  83. wx.createComponent(Component);