mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
fix(vue): correctly handle platform specific icons (#22200)
resolves #19078
This commit is contained in:
44
packages/vue/src/components/IonIcon.ts
Normal file
44
packages/vue/src/components/IonIcon.ts
Normal file
@ -0,0 +1,44 @@
|
||||
import { h, defineComponent } from 'vue';
|
||||
import { isPlatform } from '@ionic/core';
|
||||
|
||||
export const IonIcon = defineComponent({
|
||||
name: 'IonIcon',
|
||||
props: {
|
||||
ariaLabel: String,
|
||||
color: String,
|
||||
flipRtl: Boolean,
|
||||
icon: String,
|
||||
ios: String,
|
||||
lazy: String,
|
||||
md: String,
|
||||
mode: String,
|
||||
name: String,
|
||||
size: String,
|
||||
src: String
|
||||
},
|
||||
setup(props, { slots }) {
|
||||
return () => {
|
||||
const { icon, ios, md } = props;
|
||||
|
||||
let iconToUse: typeof icon;
|
||||
if (ios || md) {
|
||||
if (isPlatform('ios')) {
|
||||
iconToUse = ios ?? md ?? icon;
|
||||
} else {
|
||||
iconToUse = md ?? ios ?? icon;
|
||||
}
|
||||
} else {
|
||||
iconToUse = icon;
|
||||
}
|
||||
|
||||
return h(
|
||||
'ion-icon',
|
||||
{
|
||||
...props,
|
||||
icon: iconToUse
|
||||
},
|
||||
slots
|
||||
)
|
||||
}
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user