Giter VIP home page Giter VIP logo

Comments (5)

yejiajiehz avatar yejiajiehz commented on June 1, 2024 2

@yanxi-me

// 如果已经引用过其他版本,wx 变量结果是 undefined
const wx = require('weixin-js-sdk')

// 正确写法
const wx = window.jWeixin || require('weixin-js-sdk')

from weixin-js-sdk.

yejiajiehz avatar yejiajiehz commented on June 1, 2024

如果是直接引入浏览器是不存在这个问题的
只有在 npm 多模块引用的情形下 会形成我上面的结构
CommonJS 版本需要处理这个问题

from weixin-js-sdk.

yanxi123-com avatar yanxi123-com commented on June 1, 2024

由于代码里会判断 window.jWeixin
如果其他包里引用了 其他版本的 weixin-js-sdk ,再次引用时 window.jWeixin 已经存在
导致代码逻辑不正确

既然代码里判断了 window.jWeixin,如果之前引入过其他版本的包,再次引入时就不会执行相关代码啊

from weixin-js-sdk.

yanxi123-com avatar yanxi123-com commented on June 1, 2024

@yejiajiehz 明白了,谢谢

from weixin-js-sdk.

yanxi123-com avatar yanxi123-com commented on June 1, 2024

新版本已经解决此问题

from weixin-js-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.