


Summarize and share some practical knowledge in small program development
Jan 26, 2022 am 10:50 AMThis article summarizes and shares with you some practical knowledge in small program development. I hope it will be helpful to everyone!
Understand the rendering principle of the mini program
Background
In web development, since js is single-threaded, scripts sometimes run for a long time, causing the page to lose response. There are currently three ways to render pages:
- Pure client-side native technology rendering
- Pure web technology rendering
- Hybrid rendering, that is, a combination of web and native rendering Method
In the mini program, the Hybrid rendering method is selected, the logic layer and the view layer are separated, and run using dual threads. WebView is used to render the interface of the view layer, and the logic layer runs in JSCore.
Dual-thread model of mini program:
- Logic layer: Create a separate thread to execute javascript. All code related to the business logic of the mini program is executed here, responsible for the logic Processing, data requests, interface calls.
- View layer: Interface rendering is executed in the webView thread, and which interfaces are controlled through the logic layer code
- jsBridge: Enables small programs to use native functions through the API
Do you really understand the connection between appId, uniId and openId
openID
openID is assigned uniformly to users by the WeChat public platform. As we all know, WeChat mini programs and WeChat public accounts are maintained on the WeChat public platform. In order to distinguish users, each public account and mini program provides a unique ID for each user. Each user generates a unique openID
UnionID
UnionID is the ID assigned to WeChat users by the WeChat open platform. For applications under the same open platform, WeChat users will have a unique UnionID
For example: your company has two applications, mini program A and WeChat official account B, user information of A and B is required By opening up, two applications A and B can be bound to the same open platform. The WeChat open platform will generate a unique UnionID for WeChat users. After authorized login and registration, the UnionID will be stored in the user table, and will be opened from the same open platform in the future. After other applications under the platform are authorized to log in and get the UnionID, they can directly return the user information,
AppID
AppID is the unique identifier of different applications
For example: your company has one mini program, one official account and two applications, AppId is the unique identifier of these two applications
Take you to summarize the jumping ability of the mini program, so that you can accept leadership inspection at any time
A friend today He complained to me that he is currently working in a small and medium-sized company. The bosses are having a meeting in the conference room. The big boss has a question about mini program jump. A leader A, who didn't know which part he was responsible for, came out and first asked about operation and maintenance, and then asked about back-end Java. Java boss said that this belongs to the front-end category, and they were more clear. After hearing this, leader A directly said, what does the front-end know? Then he walked into the conference room and gave feedback to the big boss. No one knew. He told me before that their company’s front-end status is low. This is really low.
h5 Jump Mini Program
Product: Xiaoyang , our official account needs to jump to a certain applet by clicking this button. This function must be implemented
Okay, now that we have the requirements, let’s start with the plan
- Option 1: Click the button, give a pop-up box, and put it in the pop-up box A QR code. Guide users to long press to identify the
- operation process field, the user conversion rate is low, and most users are basically too lazy to operate
- Option 2: Use WeChat’s open label wx -open-launch-weapp
- You can jump to any legal and compliant mini program (I feel there will be more restrictions on this function later)
Passed After discussing with the product, the second option is more suitable. Start with:
Steps:
- Certified service account, bind the service account to the "js interface security domain name" Web pages under "can use this tag to jump to any legal and compliant mini program
- Introduce js files https://res.wx.qq.com/open/js/jweixin-1.6.0.js
- Inject permission configuration through the config interface, and apply for the required open tags through the openTagList field
wx.config({ debug: false, appId: '', // 公眾號唯一標(biāo)識 timestamp: '', // 生成簽名的時間戳 nonceStr: '', // 生成簽名的隨機串 signature: '', // 簽名 jsApiList: ["wx-open-launch-weapp"], openTagList: ["wx-open-launch-weapp"] // 微信開放標(biāo)簽 小程序跳轉(zhuǎn)按鈕:<wx-open-launch-weapp> }); // 通過ready處理成功驗證 wx.ready(function () { console.log('ready') }) // 處理失敗驗證 wx.error(function(error) { console.error("err", error); }); <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: 12px }</style> <button class="btn">打開小程序</button> </script> </wx-open-launch-weapp>
The WeChat customer service message contains a jump applet link
文本內(nèi)容....<a href='' data-miniprogram-appid='{{appid}}' data-miniprogram-path='pages/index/index'>點擊跳小程序</a>
- data-miniprogram-appid填寫小程序鏈接,表示跳轉(zhuǎn)小程序
- data-miniprogram-path 小程序路徑,可帶參數(shù)
- 公眾號必須和小程序相關(guān)聯(lián)
- 鏈接中的各個屬性值必須使用單引號
小程序跳轉(zhuǎn)小程序
wx.navigateToMiniProgram({ envVersion: 'release', // 要打開的小程序版本,develop: 開發(fā)版,trial:體驗版,release:正式版。僅在當(dāng)前小程序為開發(fā)版或體驗版時此參數(shù)有效。 appId: ’‘, // 跳轉(zhuǎn)appid path: ’‘ // 跳轉(zhuǎn)路徑 })
- 需要用戶手動觸發(fā)
- 需要用戶確認(rèn)跳轉(zhuǎn)
【相關(guān)學(xué)習(xí)推薦:小程序開發(fā)教程】
The above is the detailed content of Summarize and share some practical knowledge in small program development. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

With the popularity of mobile Internet technology and smartphones, WeChat has become an indispensable application in people's lives. WeChat mini programs allow people to directly use mini programs to solve some simple needs without downloading and installing applications. This article will introduce how to use Python to develop WeChat applet. 1. Preparation Before using Python to develop WeChat applet, you need to install the relevant Python library. It is recommended to use the two libraries wxpy and itchat here. wxpy is a WeChat machine

Implementing card flipping effects in WeChat mini programs In WeChat mini programs, implementing card flipping effects is a common animation effect that can improve user experience and the attractiveness of interface interactions. The following will introduce in detail how to implement the special effect of card flipping in the WeChat applet and provide relevant code examples. First, you need to define two card elements in the page layout file of the mini program, one for displaying the front content and one for displaying the back content. The specific sample code is as follows: <!--index.wxml-->&l

According to news from this site on October 31, on May 27 this year, Ant Group announced the launch of the "Chinese Character Picking Project", and recently ushered in new progress: Alipay launched the "Chinese Character Picking-Uncommon Characters" mini program to collect collections from the society Rare characters supplement the rare character library and provide different input experiences for rare characters to help improve the rare character input method in Alipay. Currently, users can enter the "Uncommon Characters" applet by searching for keywords such as "Chinese character pick-up" and "rare characters". In the mini program, users can submit pictures of rare characters that have not been recognized and entered by the system. After confirmation, Alipay engineers will make additional entries into the font library. This website noticed that users can also experience the latest word-splitting input method in the mini program. This input method is designed for rare words with unclear pronunciation. User dismantling

Mini programs can use react. How to use it: 1. Implement a renderer based on "react-reconciler" and generate a DSL; 2. Create a mini program component to parse and render DSL; 3. Install npm and execute the developer Build npm in the tool; 4. Introduce the package into your own page, and then use the API to complete the development.

How uniapp can achieve rapid conversion between mini programs and H5 requires specific code examples. In recent years, with the development of the mobile Internet and the popularity of smartphones, mini programs and H5 have become indispensable application forms. As a cross-platform development framework, uniapp can quickly realize the conversion between small programs and H5 based on a set of codes, greatly improving development efficiency. This article will introduce how uniapp can achieve rapid conversion between mini programs and H5, and give specific code examples. 1. Introduction to uniapp unia

This article brings you some related issues about WeChat mini programs. It mainly introduces how to use official account template messages in mini programs. Let’s take a look at them together. I hope it will be helpful to everyone.

Implementation idea: Establishing the server side of thread, so as to process the various functions of the chat room. The establishment of the x02 client is much simpler than the server. The function of the client is only to send and receive messages, and to enter specific characters according to specific rules. To achieve the use of different functions, therefore, on the client side, you only need to use two threads, one is dedicated to receiving messages, and the other is dedicated to sending messages. As for why not use one, that is because, only

Geolocation positioning and map display of PHP and mini programs Geolocation positioning and map display have become one of the necessary functions in modern technology. With the popularity of mobile devices, people's demand for positioning and map display is also increasing. During the development process, PHP and applets are two common technology choices. This article will introduce you to the implementation method of geographical location positioning and map display in PHP and mini programs, and attach corresponding code examples. 1. Geolocation in PHP In PHP, we can use third-party geolocation
