有react 的 微信扫码登录的Dome吗?
发布于 5 年前 作者 thomas0836 4546 次浏览 来自 问答

问题一: 微信的扫码登录需要引入一个js资源,http://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js 这个在react 内怎么引入? 在index.html 内?如果我想在某个组件给调用的时候才引入,该怎么办?不会是

class WechatLogin extends PureComponent {
  render() {
	  return ( 
		<> 
		  <script src="http://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js" />
		  <div id='wechatLogin'> test</div>
		</>
	  )
  }
}

问题二:微信的扫码登录中需要

new WxLogin({
  id: "wechatLogin", 
  appid: config.wechatAppid, 
  scope: "snsapi_login", 
  redirect_uri: "#{Config.api.gicWechat}/base/getUserForWebapp",
  state,
  style: "",
  href: ""
 })

这个应该写什么地方? PureComponent 的类里面?componentDidMount() 里面?

找了半天还是没有找到类似的Demo,有的大神求分享一下。

5 回复

首先呢你得把demo写对。

没有人知道吗?

vue的扫描登陆 原理差不多 不用交三百快钱的 扫码

回到顶部