EASYAIuniappNewUI/node_modules/@tuniao/tnui-vue3-uniapp/components/icon/src/icon.vue
2025-02-08 18:50:38 +08:00

46 lines
1.2 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script lang="ts" setup>
import { iconEmits, iconProps } from './icon'
import { useIcon } from './composables'
// 依赖tn-icon样式(由于uniapp在小程序端支持svg有点问题所以这里还是使用iconfont)
// #ifdef APP-PLUS
import '@tuniao/tn-icon/dist/https/index.css'
// #endif
// #ifndef APP-PLUS
import '@tuniao/tn-icon/dist/index.css'
// #endif
const props = defineProps(iconProps)
const emits = defineEmits(iconEmits)
const { isImg, iconClass, iconStyle } = useIcon(props)
// 图标点击事件
const handleClick = () => {
emits('click')
}
</script>
// #ifdef MP-WEIXIN
<script lang="ts">
export default {
options: {
// 在微信小程序中将组件节点渲染为虚拟节点更加接近Vue组件的表现(不会出现shadow节点下再去创建元素)
virtualHost: true,
},
}
</script>
// #endif
<template>
<view :class="[iconClass]" :style="iconStyle" @tap="handleClick">
<!-- 图片图标 -->
<image v-if="isImg" class="image" :src="name" :mode="imgMode" />
<!-- 正常图标 -->
<text v-else :class="['icon', `tn-icon-${name}`]" />
</view>
</template>
<style lang="scss" scoped>
@import '../../../theme-chalk/src/icon.scss';
</style>