feat: 新增 jsx/tsx 支持

Former-commit-id: a7e79341d7e4c6d89b64e733834810e92b295bd6
This commit is contained in:
hxr
2023-10-22 00:03:41 +08:00
parent 32955fd390
commit 6b5cbba7cd
4 changed files with 50 additions and 3 deletions

View File

@@ -0,0 +1,41 @@
<script setup lang="ts">
import SvgIcon from "@/components/SvgIcon/index.vue";
import { translateRouteTitle } from "@/utils/i18n";
const props = defineProps({
icon: {
type: String,
default: "",
},
title: {
type: String,
default: "",
},
});
const vnodes: any[] = [];
if (props.icon) {
if (props.icon.includes("el-icon")) {
vnodes.push(h("i", { class: [props.icon, "sub-el-icon"] }));
} else {
vnodes.push(h(SvgIcon, { "icon-class": props.icon }));
}
}
if (props.title) {
vnodes.push(h("span", { slot: "title" }, translateRouteTitle(props.title)));
}
const render = h("div", vnodes);
</script>
<template>
<render />
</template>
<style scoped>
.sub-el-icon {
width: 1em;
height: 1em;
color: currentcolor;
}
</style>