mirror of
https://github.com/youzan/vant.git
synced 2025-10-21 11:17:41 +00:00
fix(Image): memory leak during SSR (#6721)
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { createNamespace, isDef, addUnit } from '../utils';
|
import { createNamespace, isDef, addUnit, inBrowser } from '../utils';
|
||||||
import Icon from '../icon';
|
import Icon from '../icon';
|
||||||
|
|
||||||
const [createComponent, bem] = createNamespace('image');
|
const [createComponent, bem] = createNamespace('image');
|
||||||
@@ -69,7 +69,7 @@ export default createComponent({
|
|||||||
created() {
|
created() {
|
||||||
const { $Lazyload } = this;
|
const { $Lazyload } = this;
|
||||||
|
|
||||||
if ($Lazyload) {
|
if ($Lazyload && inBrowser) {
|
||||||
$Lazyload.$on('loaded', this.onLazyLoaded);
|
$Lazyload.$on('loaded', this.onLazyLoaded);
|
||||||
$Lazyload.$on('error', this.onLazyLoadError);
|
$Lazyload.$on('error', this.onLazyLoadError);
|
||||||
}
|
}
|
||||||
|
@@ -3,6 +3,7 @@ import Vue from 'vue';
|
|||||||
export { createNamespace } from './create';
|
export { createNamespace } from './create';
|
||||||
export { addUnit } from './format/unit';
|
export { addUnit } from './format/unit';
|
||||||
|
|
||||||
|
export const inBrowser = typeof window !== 'undefined';
|
||||||
export const isServer: boolean = Vue.prototype.$isServer;
|
export const isServer: boolean = Vue.prototype.$isServer;
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||||
|
Reference in New Issue
Block a user