Using runtime to implement weex jump to native PAGE

1、 Brief description

Recently, the project team plans to introduce weex and has selected a page to test the water. The page is very simple, mainly to obtain the data, render the page, and jump to the specified page. Weex is really much simpler than using RN before. We can see from the figure below that the weex page needs to jump to the original page, and we may not be able to write it dead. In other words, as long as the native page has been written in the project before, it can be called arbitrarily using weex in theory. So the problem is, my original page may only know the name. How can I pass values for that page? For example, there is a page orderdetailvc. When jumping, you need to pass in OrderID, that is, orderdetailvc. OrderID = @ "123";

2、 Thinking

Perhaps the most direct idea is to directly provide a method for weex to pass in OrderID and then push. But what if tomorrow we need to jump to another page, merchant detail VC? What it needs is not OrderID, but a merchant ID or even more parameters. How can we achieve arbitrary jump? My idea is that I wrote the project and need to jump to which class, so I must be clear about the class name and what parameters this class should need. It's just that I may not know how to use weex to pass its parameters. If I know the class name, it means that I know the class and I can find the class, then I know what properties the class has. I can get all the properties of the class, but some I need to assign values to it and some I don't need to deal with.

3、 Realize

The overall idea is: native provides a general jump method for weex. Parameters are class names and attribute dictionaries.

After the method is provided, weex can be called as follows:

After determining the solution, the only thing left is how to implement the method provided to weex. The code is as follows:

After small-scale self-test, it is found that the requirements can be realized. However, due to the short implementation time, there may be deficiencies. Please refer to it carefully. If you have any questions, please leave me a message and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>