https://res.wx.qq.com/open/js/jweixin-1.6.0.js
微信受權配置小程序
window.wx.config({ ...otherConfig, openTagList: ['wx-open-launch-weapp'] })
調用示例微信
const style = { position: 'absolute', top: 0, right: 0, bottom: 0, left: 0, }; function OpenWeapp({ originId, pagePath }) { return ( <wx-open-launch-weapp username={originId} path={pagePath} style={style}> <script type="text/wxtag-template"> <div style={style} /> </script> </wx-open-launch-weapp> ); } // 使用方式 <div style={{ position: 'relative' }}> 點擊跳轉小程序 <OpenWeapp originId="gh_xxxxxxxx" pagePath="pages/home/index?user=123&action=abc" /> </div>
因爲wx-open-launch-weapp設置樣式比較困難,故放棄設置樣式,將wx-open-launch-weapp做爲一個透明的佔位元素,撐滿父元素,也能達到預期的功能app