background
A project of front-end Time company needs such a function: the page of wechat public account needs to jump to the small program. So I’m going to do some research.
explore
I finally found it by consulting wechat official documents.
Wechat jump small program open labelwx-open-launch-weapp
Opening Premise:
- The web page bound to the “JS interface security domain name” by the authenticated service number can use this label to jump to any legal and compliant small program.
- Certified non-personal subject small program, the use of small program cloud development of static web hosting binding domain name under the web page, can use this label to jump to any legal compliance small program.
Without further ado, go directly to the code:
<wx-open-launch-weapp id="launch-btn" username="gh_xxxxxxxx" path="pages/home/index? user=123&action=abc" > <script type="text/wxtag-template"> <style>.btn { padding: 12 px} < / style > < button class = "BTN" > open the small program < / button > < / script > < / wx - open - launch - weapp > < script > var BTN = document.getElementById('launch-btn'); btn.addEventListener('launch', function (e) { console.log('success'); }); btn.addEventListener('error', function (e) { console.log('fail', e.detail); }); </script>Copy the code
An unknown place, please pay close attention to WeChat official document: developers.weixin.qq.com/doc/offiacc…
The last
If you have any questions, please leave a message to discuss and grow together