@fe6/icon-cube-vue
Version:
Water Icon 的支持自定义图标
47 lines (42 loc) • 1.31 kB
JavaScript
import { createVNode } from 'vue';
import * as mapIcon from './map';
var toPascalCase = function toPascalCase(val) {
return val.replace(/(^w|-w)/g, function (c) {
return c.slice(-1).toUpperCase();
});
};
var IIconWaterOptions = {
name: 'icon-keg',
props: ['size', 'strokeWidth', 'strokeLinecap', 'strokeLinejoin', 'theme', 'colors', 'spin', 'type'],
render: function render() {
var type = toPascalCase(this.type);
if (!(type in mapIcon)) {
throw new Error("".concat(type, " is not a valid icon type name"));
}
var size = this.size,
strokeWidth = this.strokeWidth,
strokeLinecap = this.strokeLinecap,
strokeLinejoin = this.strokeLinejoin,
theme = this.theme,
colors = this.colors,
spin = this.spin;
return createVNode(mapIcon[this.type], {
size: size,
strokeWidth: strokeWidth,
strokeLinecap: strokeLinecap,
strokeLinejoin: strokeLinejoin,
theme: theme,
colors: colors,
spin: spin
});
}
};
export var IconKeg = IIconWaterOptions;
export var iconKegInstall = function iconKegInstall(Vue, prefix) {
Object.values(mapIcon).forEach(function (icon) {
if (icon.name) {
Vue.component(prefix ? prefix + '-' + icon.name.slice(5) : icon.name, icon);
}
;
});
};