Jump to another applet in WeChat applet (multiple implementations)

Today in the project, I just encountered a jump from the current applet to another applet. Let me share with you a few simple jump methods I summarized.

method one:

1. Configure the appid and applet page path to be redirected

	wx.navigateToMiniProgram({
    
    
	    appId: '目标小程序appid',
	    path: '目标小程序页面路径',
	    //develop开发版;trial体验版;release正式版
	    envVersion: 'release', 
	    success(res) {
    
    
	      // 打开成功
	      console.log("跳转小程序成功!",res);
	    } 
	})

If the path attribute is not given, it will jump to the homepage of the target applet by default. If you want to jump to other pages, you need to configure the path attribute, so that you can jump from the current WeChat applet to another applet~

Method 2:

What if you don't know the appid and page path of the target applet?

There is also a way, which is to use the shortLink attribute to realize the link jump, click the upper right corner of the applet, and select "Copy Link"
insert image description here

Code

	wx.navigateToMiniProgram({
    
    
	    shortLink:'目标小程序链接',
	    //develop开发版;trial体验版;release正式版
	    envVersion: 'release', 
	    success(res) {
    
    
	      // 打开成功
	      console.log("跳转小程序成功!",res);
	    } 
	})

The second way is to use it when you don’t know the appid of the applet, but if you use the shortLink attribute to jump, the default is to jump to the home page of the target applet~

How can I get the page path of the applet if I want to use the appid to jump, but there is no source code?

In fact, on the WeChat public platform, you can get the page path through settings. How to do it, let’s see the next chapter "Get the page path of the applet"

Guess you like

Origin blog.csdn.net/qq_46665317/article/details/130862992