mirror of
https://github.com/iconify/iconify.git
synced 2024-12-05 02:33:16 +00:00
feat(vue): compatible with SSR
This commit is contained in:
parent
b1ebdde8a9
commit
9ed21a9e97
@ -243,6 +243,12 @@ export const Icon = defineComponent<IconProps>({
|
||||
// Set initial data
|
||||
data() {
|
||||
return {
|
||||
// Current icon name
|
||||
_name: '',
|
||||
|
||||
// Loading
|
||||
_loadingIcon: null,
|
||||
|
||||
// Mounted status
|
||||
iconMounted: false,
|
||||
|
||||
@ -252,12 +258,6 @@ export const Icon = defineComponent<IconProps>({
|
||||
},
|
||||
|
||||
mounted() {
|
||||
// Current icon name
|
||||
this._name = '';
|
||||
|
||||
// Loading
|
||||
this._loadingIcon = null;
|
||||
|
||||
// Mark as mounted
|
||||
this.iconMounted = true;
|
||||
},
|
||||
@ -354,7 +354,7 @@ export const Icon = defineComponent<IconProps>({
|
||||
const props = this.$attrs;
|
||||
|
||||
// Get icon data
|
||||
const icon: IconComponentData | null = this.iconMounted
|
||||
const icon: IconComponentData | null = (this.iconMounted || props.ssr)
|
||||
? this.getIcon(props.icon, props.onLoad)
|
||||
: null;
|
||||
|
||||
|
@ -67,4 +67,9 @@ interface IconifyElementProps {
|
||||
/**
|
||||
* Mix of icon properties and HTMLElement properties
|
||||
*/
|
||||
export type IconProps = IconifyElementProps & IconifyIconProps;
|
||||
export interface IconProps extends IconifyElementProps, IconifyIconProps {
|
||||
/**
|
||||
* Try load icon on first render during SSR
|
||||
*/
|
||||
ssr?: boolean
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user