refactor: icon component

This commit is contained in:
Fine 2022-12-16 10:49:26 +08:00
parent f8cd2849d2
commit f6b075c11c
2 changed files with 3 additions and 9 deletions

View File

@ -24,22 +24,16 @@ limitations under the License. -->
loading, loading,
}" }"
> >
<use :href="symbolId"></use> <use :href="`#${iconName}`"></use>
</svg> </svg>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { computed } from "vue";
/*global defineProps */ /*global defineProps */
const props = defineProps({ defineProps({
iconName: { type: String, default: "" }, iconName: { type: String, default: "" },
size: { type: String, default: "sm" }, size: { type: String, default: "sm" },
loading: { type: Boolean, default: false }, loading: { type: Boolean, default: false },
prefix: {
type: String,
default: "icon",
},
}); });
const symbolId = computed(() => `#${props.prefix}-${props.iconName}`);
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.icon { .icon {

View File

@ -48,7 +48,7 @@ export default ({ mode }: ConfigEnv): UserConfig => {
// Specify the icon folder to be cached // Specify the icon folder to be cached
iconDirs: [path.resolve(__dirname, "./src/assets/icons")], iconDirs: [path.resolve(__dirname, "./src/assets/icons")],
// Specify symbolId format // Specify symbolId format
symbolId: "icon-[dir]-[name]", symbolId: "[name]",
}), }),
], ],
resolve: { resolve: {