In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how to jump from Wechat card package to Mini Program. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Wechat card package jumps to Mini Program
First sort out the Mini Program life cycle * * Mini Program life cycle
OnLaunch lifecycle function-monitors Mini Program initialization when Mini Program initialization is completed, triggers onLaunch (global trigger only once) onShow lifecycle function-listens Mini Program shows that when Mini Program starts or enters foreground display, it triggers onShowonHide lifecycle function-listens Mini Program hides when Mini Program enters background, triggers onHideonError error listening function when Mini Program has script error Or when the api call fails, onError will be triggered with an error message
Some examples
App ({onLaunch: function (options) {console.log ("app.js-onLaunch---");}, onShow:function () {console.log ("app.js-onShow---");}, onHide:function () {console.log ("app.js-onHide---");}, onError: function (msg) {console.log ("app.js-onError---") }, globalData: {userInfo: null}})
The print result is as follows
So far, we know the life cycle execution sequence and trigger conditions of Mini Program.
Wechat Card packet Jump Mini Program can use the onshow method onshow (options) in app.js to obtain the parameters through options. It is worth noting that all the parameters obtained by options in the onshow in app.js are encapsulated in query, that is, options.query, to obtain the parameters for entering Mini Program.
Pit: the parameters are different. App.js cache originally thought that the parameters obtained in app.js are the same as those obtained by general page onload, but they are actually different. It is recommended to re-assign the parameter onLoad: function (options) {} when you onload the page, so that the latest parameters will be obtained each time as shown below.
A little bit of configuration with card package
Add or modify membership card fields https://api.weixin.qq.com/card/update?access_token=token{ "card_id": "pEVBpxI6Fb7xqUUfrTiD738NZht4", "member_card": {"custom_field2": {"name": "Home Mini programs", "app_brand_pass": "home/pages/index/index" "app_brand_user_name": "gh_69986111111@app"} pay special attention to: this app_brand_user_name is not the official account, but the original ID of Mini Program plus @ appapp_brand_user_name, so you can add or modify the membership card to jump. Url is also needed. {"card_id": "pEVBpxI6Fb7xqUUfrTiD738NZht4", "member_card": {"custom_field2": {"url": "http://baidu.com",// this URL must have" name ":" Home applet "," app_brand_pass ":" home/pages/index/index " "app_brand_user_name": "gh_69986111111@app"} Thank you for reading! This is the end of the article on "how to jump from Wechat card bag to Mini Program". I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.