Open a wechat mini program on top of another mini program

206 views Asked by At

Consider there are two authenticated WeChat mini-programs. Can I open a mini program on top of another mini program using an iframe?- Not using navigateToMiniProgram API but I am asking like embedding one on top of another.

I have searched the documentation and a few other blogs/white papers. I was not able to find anything relevant to it.

1

There are 1 answers

0
Jaime Roman On

As far as I know, it is not possible to embed a wechat page inside another.

The best way I found to simulate this behavior was to create a component with the elements that I need to embed so that I can use it anywhere.

Suppose you have a login page that you can show if you go to the login page as such or you want to have a sidebar in case the user has not logged in.

You create a component with the login (I'm going to put a pseudo code, now I don't remember the wechat syntax well)

<view>username</view>
<input name='username'></input>
<view>pass</view>
<input name='pass'></input>

Then in your page where you want to embed said component you just add the component.

<view>
   <!-- login component -->
   <login-component></login-component>
</view>

I hope this helps you