From a895af9f99bc981f316e568f6c766a9974d2f8c5 Mon Sep 17 00:00:00 2001 From: yanxi Date: Tue, 17 Oct 2023 22:21:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20window=20=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1=E6=A3=80=E6=9F=A5,=20=E5=B9=B6=E4=BF=9D=E8=AF=81?= =?UTF-8?q?=E6=AF=8F=E6=AC=A1=E9=83=BD=E8=BF=94=E5=9B=9E=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E7=9A=84=20wx=20=E5=AF=B9=E8=B1=A1,=20=E9=81=BF=E5=85=8D?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E5=BC=95=E7=94=A8=E6=97=B6=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=20undefined?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 3eb3b5d..ffa92f2 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,10 @@ !(function (e, n) { module.exports = n(e); -})(window, function (r, e) { +})(typeof window === "object" && window, function (r, e) { + if (!r) { + console.warn("can't use weixin-js-sdk in server side"); + return {}; + } var a, c, n, i, t, o, s, d, l, u, p, f, m, g, h, S, y, I, v, _, w, T; if (!r.jWeixin) return ( @@ -722,6 +726,7 @@ e && (r.wx = r.jWeixin = _), _ ); + else return r.jWeixin; function k(n, e, i) { r.WeixinJSBridge ? WeixinJSBridge.invoke(n, P(e), function (e) {