Skip to content

Commit

Permalink
fix(runtime): 修复支付宝小程序下 Vue3 报错,fix #9153
Browse files Browse the repository at this point in the history
之前为了修复 #8684,支付宝环境下 providePlugin 不提供模拟的 navigator 对象,
而是使用全局自带的 navigator 对象。
但支付宝的 navigator 对象在真机中没有 userAgent 属性,只有 swuserAgent,
这会引起 Vue3 报错,因此予以兼容。
  • Loading branch information
Chen-jj committed Apr 26, 2021
1 parent 60b388a commit 80c8fe1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/taro-alipay/src/runtime.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import { mergeReconciler, mergeInternalComponents } from '@tarojs/shared'
import { hostConfig, components } from './runtime-utils'

// 支付宝真机只有 navigator.swuserAgent
const { userAgent } = navigator
Object.defineProperty(navigator, 'userAgent', {
configurable: true,
enumerable: true,
get () {
return userAgent || (navigator as any).swuserAgent || ''
}
})

mergeReconciler(hostConfig)
mergeInternalComponents(components)

0 comments on commit 80c8fe1

Please sign in to comment.