fix(Image): memory leak during SSR (#6721)

This commit is contained in:
neverland 2020-07-07 14:58:59 +08:00 committed by GitHub
parent 89fdbf4729
commit 710208eee0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -1,4 +1,4 @@
import { createNamespace, isDef, addUnit } from '../utils';
import { createNamespace, isDef, addUnit, inBrowser } from '../utils';
import Icon from '../icon';
const [createComponent, bem] = createNamespace('image');
@ -69,7 +69,7 @@ export default createComponent({
created() {
const { $Lazyload } = this;
if ($Lazyload) {
if ($Lazyload && inBrowser) {
$Lazyload.$on('loaded', this.onLazyLoaded);
$Lazyload.$on('error', this.onLazyLoadError);
}

View File

@ -3,6 +3,7 @@ import Vue from 'vue';
export { createNamespace } from './create';
export { addUnit } from './format/unit';
export const inBrowser = typeof window !== 'undefined';
export const isServer: boolean = Vue.prototype.$isServer;
// eslint-disable-next-line @typescript-eslint/no-empty-function