SSvg.js 789 B

123456789101112131415161718192021222324252627
  1. import { openBlock as t, createElementBlock as i, createElementVNode as n } from "vue";
  2. const r = ["width", "height", "fill"], l = ["xlink:href"], a = {
  3. __name: "SSvg",
  4. props: {
  5. // 雪碧图里的图标 id(不带 icon- 前缀,对应 <symbol id="icon-xxx">)
  6. name: { type: String },
  7. // 图标尺寸,宽高取同一个值;不传时由外部 CSS 控制
  8. size: { type: [String, Number] },
  9. // 填充色;不传则用 currentColor 跟随文字颜色
  10. color: { type: String }
  11. },
  12. setup(e) {
  13. return (o, c) => (t(), i("svg", {
  14. "aria-hidden": "true",
  15. width: e.size,
  16. height: e.size,
  17. fill: e.color
  18. }, [
  19. n("use", {
  20. "xlink:href": `#icon-${e.name}`
  21. }, null, 8, l)
  22. ], 8, r));
  23. }
  24. };
  25. export {
  26. a as default
  27. };