Skip to content

Commit

Permalink
fix(mp-weixin): requirePlugin报错wx.__webpack_require_UNI_MP_PLUGIN__ i…
Browse files Browse the repository at this point in the history
…s not a function closed dcloudio#4301
  • Loading branch information
StrivingRabbit committed May 11, 2023
1 parent 6cf88d4 commit 4590421
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/uni-mp-weixin/dist/wx.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,29 @@ const objectKeys = [
'serviceMarket',
'router',
'worklet',
'__webpack_require_UNI_MP_PLUGIN__'
]
const singlePageDisableKey = [
'lanDebug',
'router',
'worklet',
'worklet'
]
const target = typeof globalThis !== 'undefined' ? globalThis : (function() {
const target = typeof globalThis !== 'undefined' ? globalThis : (function () {
return this
})()

const key = ['w', 'x'].join('')
const oldWx = target[key]
const launchOption = oldWx.getLaunchOptionsSync ? oldWx.getLaunchOptionsSync() : null

function isWxKey(key) {
function isWxKey (key) {
if (launchOption && launchOption.scene === 1154 && singlePageDisableKey.includes(key)) {
return false
}
return objectKeys.indexOf(key) > -1 || typeof oldWx[key] === 'function'
}

function initWx() {
function initWx () {
const newWx = {}
for (const key in oldWx) {
if (isWxKey(key)) {
Expand Down

0 comments on commit 4590421

Please sign in to comment.