diff --git a/src/index.ts b/src/index.ts index 4c6b075..32187f1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,9 +15,12 @@ class VueShopItem extends Vue { @Prop({ default: true }) readonly showPreview!: boolean; @Prop({ default: 'left' }) readonly previewPosition!: string; - isMobile() { + isMobile(): boolean | undefined { + if (!window) { + return; + } return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i - .test(navigator.userAgent); + .test(window.navigator.userAgent); } }