CN112162871A - Method, device and storage medium for data exchange between applet and webview - Google Patents
Method, device and storage medium for data exchange between applet and webview Download PDFInfo
- Publication number
- CN112162871A CN112162871A CN202011023595.4A CN202011023595A CN112162871A CN 112162871 A CN112162871 A CN 112162871A CN 202011023595 A CN202011023595 A CN 202011023595A CN 112162871 A CN112162871 A CN 112162871A
- Authority
- CN
- China
- Prior art keywords
- applet
- webview
- data
- page
- link
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 45
- 238000004590 computer program Methods 0.000 claims description 6
- 230000005540 biological transmission Effects 0.000 abstract description 6
- 238000004891 communication Methods 0.000 abstract description 6
- 230000000694 effects Effects 0.000 abstract description 2
- 238000005516 engineering process Methods 0.000 description 4
- 230000003111 delayed effect Effects 0.000 description 3
- 230000003993 interaction Effects 0.000 description 3
- 230000006870 function Effects 0.000 description 2
- 230000001960 triggered effect Effects 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/543—User-generated data transfer, e.g. clipboards, dynamic data exchange [DDE], object linking and embedding [OLE]
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/95—Retrieval from the web
- G06F16/955—Retrieval from the web using information identifiers, e.g. uniform resource locators [URL]
- G06F16/9566—URL specific, e.g. using aliases, detecting broken or misspelled links
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Stored Programmes (AREA)
Abstract
The application relates to a method, a device and a storage medium for data exchange between an applet and webview, wherein the method comprises the following steps: when the webview jumps to an applet interface, a current webpage link is added to an applet page address transmission parameter; after the jump, the small program interface receives and stores the transmitted webpage link in the memory; returning the small program page to the webview after the small program page processes the service logic, and returning the returned data and the stored webpage link to the webview when returning to the webview; splicing the returned data and the stored webpage links to serve as new links, and using the new links as the webpage links in the webview; acquiring data returned from the applet; and restoring the new link into the original webpage link. The method and the device have the effect of perfecting a communication system between the small program and the webview.
Description
Technical Field
The present application relates to the field of data exchange, and in particular, to a method, an apparatus, and a storage medium for data exchange between an applet and webview.
Background
Applets provide a development framework and API that helps developers develop native APP in the micro-trusted domain. The webview is a container for bearing a webpage, can be embedded in a mobile terminal, and realizes mixed development of a front end.
With the development of more and more small program developers by the aid of front-end technologies, iterative versions of company products are complicated, rapid iteration causes the size of a small program development kit to increase day by day, capacity exceeds a limit, each online process needs to be approved by a WeChat person, and the approval time is uncontrollable. Part of the function pages need to be cut into webview to solve the capacity problem and part of the issue limitation problem. In the related technology, the applet interface is returned to the webview, so that data cannot be brought in, and the interaction between the applet page and the webview is realized through a postMessage method given by an official party.
For the above related technologies, the inventor thinks that when an official in the related technology realizes interaction between the applet and the webview by using a postMessage method, data transmission to the applet through the webview can be realized only when a message event is triggered at a specific time, but data transmission to the webview by the applet is not supported, and the communication function is not perfect.
Disclosure of Invention
In order to improve a communication system between an applet and a webview, the application provides a method, a device and a storage medium for data exchange between the applet and the webview.
In a first aspect, the present application provides a method for exchanging data between an applet and webview, which adopts the following technical solution:
a method of applet exchange with webview data comprising the steps of:
when the webview jumps to an applet interface, a current webpage link is added to an applet page address transmission parameter; after the jump, the small program interface receives and stores the transmitted webpage link in the memory;
returning the small program page to the webview after the small program page processes the service logic, and returning the returned data and the stored webpage link to the webview when returning to the webview;
splicing the returned data and the stored webpage links to serve as new links, and using the new links as the webpage links in the webview;
acquiring data returned from the applet;
and restoring the new link into the original webpage link.
By adopting the technical scheme, the data are transmitted to the small program through the webview, and meanwhile, the small program transmits the data back to the webview. When the applet returns, the stored webpage links and returned data are spliced together, wherein the returned data are pictures or characters obtained through the applet, the returned data are spliced with the webpage links, the applet can transmit new links to the webview during returning, and communication between the applet and the webview is improved.
Optionally, when the applet returns to the webview, a fixed method is predefined in the webview, and the parameters are data and web page links received and returned by the object.
By adopting the technical scheme, the predefined fixing method is used for receiving the returned data and the webpage link, and further the data and the webpage link are transmitted when the small program is returned.
Optionally, returning the applet to the webview triggers an onShow lifecycle; in the step of setting the webpage links, the onShow lifecycle takes the returned data as a hash value, and the hash value and the stored webpage links are spliced into a new link.
By adopting the technical scheme, when the applet returns to the webview, the onShow hook is triggered to acquire the returned data and the webpage link, and the returned picture or character is used as a hash value to be spliced with the originally stored webpage link to form a new link. The original webpage link is guaranteed to be positioned when the web browser jumps back to webview through the originally stored webpage link, and the accuracy of the page jump back is improved.
Optionally, a hash event is set in the webview, the hash event monitors that the hash value changes, and the hash value in the new link is taken out, that is, the data returned in the applet is obtained.
By adopting the technical scheme, after the hash value is monitored to be changed, the hash value can be taken out, and the picture or the character returned by the applet is displayed. And finishing the interaction of the applet and the webview.
Optionally, when the new link is restored to the original web page link, executing window.
By adopting the technical scheme, the hash value can be deleted by executing the window.
Optionally, the applet page is closed after the applet page processes the service logic, and the applet page is returned to webview after being closed.
By adopting the technical scheme, the step of returning to the webview is executed to indicate that the small program page has processed the service logic, and the small program page can be returned to the webview and the subsequent data transmission operation is carried out.
Optionally, after the applet page processes the service logic, the applet page is closed after the user clicks a return button of the applet page or the user clicks any position of the applet page.
By adopting the technical scheme, the user clicks the return button or any position of the small program page.
Optionally, after the applet page processes the service logic, the applet page is delayed to be automatically closed.
By adopting the technical scheme, the small program page is closed through delayed automatic closing of the small program page, which indicates that the small program page has processed the service logic and can be subsequently operated.
In a second aspect, the present application provides an apparatus for exchanging an applet with webview data, which adopts the following technical solution:
an apparatus for applet exchange with webview data comprising a memory and a processor, the memory having stored thereon a computer program capable of being loaded by the processor and of carrying out any one of the methods described above.
By adopting the technical scheme, the method has the characteristics that the data can be returned to the webview by the applet, and the communication between the applet and the webview is realized.
In a third aspect, the present application provides a storage medium for exchanging an applet and webview data, which adopts the following technical solution:
a storage medium for applet exchange with webview data, storing a computer program capable of being loaded by a processor and executing any one of the methods described above.
By adopting the technical scheme, the corresponding program can be stored, and the method has the characteristics of supporting the applet to transmit data back to the webview and realizing communication between the applet and the webview.
In summary, the present application includes at least one of the following beneficial technical effects:
1. the method comprises the steps of acquiring returned data and restoring a webpage by transmitting webpage connection, returning an applet, setting a webpage link, transmitting the data to the applet through the webview, and simultaneously transmitting the data returned by the applet to the webview;
2. restoring the webpage by executing window.
Drawings
Fig. 1 is a block diagram showing the structure of the method of exchanging the applet with webview data disclosed in examples 1 and 2.
Detailed Description
The present application is described in further detail below with reference to fig. 1.
The embodiment of the application discloses a method for exchanging an applet and webview data.
Example one
Referring to FIG. 1, a method of applet exchange with webview data comprising the steps of:
s1, when the webview jumps to the small program interface, adding a current webpage link on the address transmission parameter of the small program page; and after the jump, the small program interface receives and stores the transmitted webpage link in the memory.
And S2, closing the small program page after the small program page finishes processing the service logic, returning to the webview after the small program page is closed, and returning the returned data and the stored webpage link to the webview together when the small program page is returned to the webview.
The business logic of the applet page can be photographing or inputting characters and the like according to different operation requirements, and the photos or the characters are used as returned data.
After the small program page processes the service logic, the user clicks a return button of the small program page or clicks any position of the small program page, and then the small program page is closed; or after the small program page processes the service logic, the small program page is delayed to be automatically closed.
A fixed method setH5Data is predefined in webview, and parameters are Data received and returned by an object and web page links and are stored in a memory. When the applet page returns to webview, the fixed method setH5Data is called first, and the returned Data and the webpage link are transmitted into the fixed method setH5Data and stored in the memory.
And S3, splicing the returned data and the stored webpage links to serve as new links, and using the new links as the webpage links in the webview.
Returning the applet to the webview triggers an onShow lifecycle hook, which is the api of the applet page. And in the onShow life cycle, the returned data is used as a hash value, the hash value and the stored webpage links are spliced into a new link, the new link is the original stored webpage link plus the hash value, and the new link is used as the webpage link in the webview.
And S4, acquiring the data returned from the applet.
And a hash event is set in the webview, the hash event monitors that the hash value changes, and the hash value in the new link is taken out, namely, the data returned in the applet is obtained.
And S5, restoring the new link to the original webpage link.
Restoring the webpage by executing window.
The embodiment of the application also discloses a device for exchanging the small program and webview data. Comprising a memory and a processor, the memory having stored thereon a computer program which can be loaded by the processor and which performs the method as described above.
The embodiment of the application also discloses a storage medium for exchanging the small program and webview data. Which stores a computer program that can be loaded by a processor and executed in a method as described above, the computer readable storage medium comprising, for example: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The above embodiments are preferred embodiments of the present application, and the protection scope of the present application is not limited by the above embodiments, so: all equivalent changes made according to the structure, shape and principle of the present application shall be covered by the protection scope of the present application.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011023595.4A CN112162871A (en) | 2020-09-25 | 2020-09-25 | Method, device and storage medium for data exchange between applet and webview |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011023595.4A CN112162871A (en) | 2020-09-25 | 2020-09-25 | Method, device and storage medium for data exchange between applet and webview |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112162871A true CN112162871A (en) | 2021-01-01 |
Family
ID=73863855
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011023595.4A Pending CN112162871A (en) | 2020-09-25 | 2020-09-25 | Method, device and storage medium for data exchange between applet and webview |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112162871A (en) |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114217866A (en) * | 2021-11-08 | 2022-03-22 | 阿里健康科技(中国)有限公司 | Applet using method and device and electronic equipment |
CN114327688A (en) * | 2022-03-15 | 2022-04-12 | Tcl通讯科技(成都)有限公司 | Data processing method, frame, storage medium and terminal equipment based on micro front end |
CN114816637A (en) * | 2022-04-27 | 2022-07-29 | 瀚云科技有限公司 | Application display method, device and system embedded into applet |
CN115567576A (en) * | 2022-10-14 | 2023-01-03 | 数字广东网络建设有限公司 | Data transmission method and device, electronic equipment and storage medium |
WO2023070834A1 (en) * | 2021-10-25 | 2023-05-04 | 同程网络科技股份有限公司 | Method and system for communication between applet and webpage, and related device |
CN116881602A (en) * | 2023-07-12 | 2023-10-13 | 中国平安人寿保险股份有限公司 | Interaction method and device of application program and webpage and computer equipment |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110704054A (en) * | 2019-09-06 | 2020-01-17 | 北京达佳互联信息技术有限公司 | Method and device for accessing target application program through applet, electronic equipment and storage medium |
CN111414525A (en) * | 2020-03-25 | 2020-07-14 | 深圳市腾讯网域计算机网络有限公司 | Data acquisition method and device for small program, computer equipment and storage medium |
-
2020
- 2020-09-25 CN CN202011023595.4A patent/CN112162871A/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110704054A (en) * | 2019-09-06 | 2020-01-17 | 北京达佳互联信息技术有限公司 | Method and device for accessing target application program through applet, electronic equipment and storage medium |
CN111414525A (en) * | 2020-03-25 | 2020-07-14 | 深圳市腾讯网域计算机网络有限公司 | Data acquisition method and device for small program, computer equipment and storage medium |
Non-Patent Citations (1)
Title |
---|
衡与墨: "微信小程序(1)——web-view和小程序间传递参数、发送消息", pages 1 - 2, Retrieved from the Internet <URL:https://blog.csdn.net/le_17_4_6/article/details/86598772> * |
Cited By (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2023070834A1 (en) * | 2021-10-25 | 2023-05-04 | 同程网络科技股份有限公司 | Method and system for communication between applet and webpage, and related device |
CN114217866A (en) * | 2021-11-08 | 2022-03-22 | 阿里健康科技(中国)有限公司 | Applet using method and device and electronic equipment |
CN114217866B (en) * | 2021-11-08 | 2023-09-19 | 阿里健康科技(中国)有限公司 | Application method and device of applet and electronic equipment |
CN114327688A (en) * | 2022-03-15 | 2022-04-12 | Tcl通讯科技(成都)有限公司 | Data processing method, frame, storage medium and terminal equipment based on micro front end |
CN114327688B (en) * | 2022-03-15 | 2022-07-08 | Tcl通讯科技(成都)有限公司 | Data processing method, frame, storage medium and terminal equipment based on micro front end |
CN114816637A (en) * | 2022-04-27 | 2022-07-29 | 瀚云科技有限公司 | Application display method, device and system embedded into applet |
CN114816637B (en) * | 2022-04-27 | 2024-03-01 | 瀚云科技有限公司 | Application display method, device and system embedded in applet |
CN115567576A (en) * | 2022-10-14 | 2023-01-03 | 数字广东网络建设有限公司 | Data transmission method and device, electronic equipment and storage medium |
CN116881602A (en) * | 2023-07-12 | 2023-10-13 | 中国平安人寿保险股份有限公司 | Interaction method and device of application program and webpage and computer equipment |
CN116881602B (en) * | 2023-07-12 | 2025-07-22 | 中国平安人寿保险股份有限公司 | Interaction method and device of application program and webpage and computer equipment |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112162871A (en) | Method, device and storage medium for data exchange between applet and webview | |
US10783211B2 (en) | Page processing method and device thereof | |
US8955739B2 (en) | Barcode scanner on webpage | |
JP5985074B2 (en) | Web resource interactivity analysis based on reload events | |
US10354244B2 (en) | Method, apparatus and system for processing payment request for virtual commodities on open network platform | |
US11615443B2 (en) | System and method to selectively update supplemental content rendered in placement regions of a rendered page | |
CN108319662A (en) | Page processing method, device, electronic equipment and readable storage medium storing program for executing | |
CN108509207A (en) | The cross-system of WEB application program is installed | |
CN110704784A (en) | Web page screenshot method, apparatus, device and computer-readable storage medium | |
WO2019072024A1 (en) | Credit-based installment service implementation method | |
CN109862076B (en) | Service data interaction method, device and system | |
CN106656920A (en) | HTTP service processing method and device | |
CN112632184A (en) | Data processing method and device, electronic equipment and storage medium | |
CN109358833B (en) | Audio playing method and system, computing device and storage medium | |
CN107948328B (en) | Information pushing method and device and electronic equipment | |
EP3242258A1 (en) | Method and apparatus for processing virtual card | |
JP2018500670A (en) | Handling unstructured messages | |
CN113115238B (en) | SMS verification code filling method and electronic device | |
CN106874485A (en) | The method and picture that a kind of picture is presented are presented device | |
CN112230944B (en) | Application installation method, device, electronic equipment and computer readable medium | |
CN114721740B (en) | Message triggering method, device, equipment and storage medium | |
CN111967929A (en) | Order polling method and device, electronic equipment and storage medium | |
CN107613486B (en) | STK module naming method, communication terminal and device with storage function | |
CN114691236B (en) | Method, device, equipment and medium for integrating native program and mini program | |
CN117539564A (en) | Page hot updating method and device, electronic equipment and readable storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20210101 |