| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <template>
- <image
- :src="resolvedSrc"
- :style="{ width: size + 'px', height: size + 'px' }"
- mode="aspectFit"
- @click="handleClick"
- />
- </template>
- <script lang="uts">
- import { iconMap } from '@/common/icon-map';
- export default {
- props: {
- name: String,
- src: String,
- size: Number,
- active: Boolean
- },
- computed: {
- resolvedSrc(): string {
- if (this.src) return this.src;
- if (this.name) {
- const key = this.active ? `${this.name}-active` : this.name;
- return iconMap[key] || iconMap[this.name] || '';
- }
- return '';
- }
- },
- methods: {
- handleClick() {
- this.$emit('click');
- }
- }
- };
- </script>
- <style>
- image {
- display: block;
- }
- </style>
|