当前位置:网站首页>uni-app进阶之内嵌应用【day14】
uni-app进阶之内嵌应用【day14】
2022-06-30 16:43:00 【华为云】

如今,各大app平台都有自己的小程序系统,各种应用可以直接嵌入app中,实现一站式体验。使用uniapp开发的应用程序如何实现这样的功能?答案是嵌入式web视图。
获取android页面中的中的webView嵌入H5页面。
WebView webView = findViewById(R.id.webView_h5);//webView.loadUrl("http://127.0.0.1/asset/pages/forAndroidAndH5.html");//嵌入H5页面添加辅助处理JS,否则一些JS函数会失败,如alert()方法
webView.setWebChromeClient(new WebChromeClient(){ public boolean onJsAlert(WebView view, String url, String message, JsResult result){ return super.onJsAlert(view, url, message, result); }});每个Vue页面实际上都是一个WebView,Vue页面中的web视图组件实际上是WebView中的一个子WebView。子WebView附加到父WebView。
Vue页面将自动覆盖整个页面,并使用@消息接收web视图页面通信;
Nvue页面需要指定页面宽度和高度,使用@onpostmessage接收web视图页面通信;
app Vue中的web视图组件不支持自定义样式,但v-show的本质是更改组件样式。也就是说,该组件支持V-IF而不是V-show。
默认情况下,<web view>组件是全屏的,并且高于前端组件。应用程序端需要使用plus规范来调整大小或覆盖其上的内容。
H5端的web视图实际上使用当前浏览器转换为iframe;
应用程序端IOS分为uiwebview和wkwebview。自2.2.5版本起,默认为wkwebview;
Nvue web视图必须指定样式宽度和高度;
应用程序网页向应用程序发送实时消息;
默认情况下,App nvue web视图没有大小。可以按样式设置大小。如果要填充整个窗口,可以将flex设置为:
1。标题栏不会在web视图页面中自动显示标题。如果要填充整个窗口并显示标题,建议使用Vue页面的web视图(无法控制默认全屏),如果要自定义web视图的大小,请使用nvue web视图;
如果参数是字符串,则需要“单引号”。如果参数是数值,则不需要该参数。如果没有参数,只需留下一个()
使用无/无参数和返回值调用JS函数
int arg1 = 10;int arg2 = 12;String methodH5 = "androidtoh5WithResult(" + arg1 + "," + arg2 + ")";webView.evaluateJavascript(methodH5, new ValueCallback<String>() { @Override public void onReceiveValue(String s) { System.out.println("=====s:" + s); }});边栏推荐
- Advanced Mathematics (Seventh Edition) Tongji University General exercises one person solution
- Php8.0 environment detailed installation tutorial
- Small tools (3) integration knife4j3.0.3 interface document
- Add code block in word (Reprint)
- Fragmentary knowledge points of MySQL
- What did Tongji and Ali study in the CVPR 2022 best student thesis award? This is an interpretation of yizuo
- Small Tools(3) 集成Knife4j3.0.3接口文档
- Grep output with multiple colors- Grep output with multiple Colors?
- Deep understanding of JVM (VI) -- garbage collection (III)
- New skill: accelerate node through code cache JS startup
猜你喜欢

Canvas cloud shape animation

DeFi借贷协议机制对比:Euler、Compound、Aave和Rari Capital

Simulation of campus network design based on ENSP

广电5G正式启航,黄金频段将如何应用引关注

ABAP-发布Restful服务

Redis (V) - advanced data types

K-line diagram must be read for quick start

Deep understanding of JVM (VI) -- garbage collection (III)

Design and principle of tubes responsive data system
![[PROJECT] Xiaomao school (IX)](/img/01/f7fc609e7a156d6e60ce6482ba2ac1.jpg)
[PROJECT] Xiaomao school (IX)
随机推荐
MSF后渗透总结
NFT铸造交易平台开发详情
Three methods of modifying time zone in MySQL
Development: how to install offline MySQL in Linux system?
流批一体在京东的探索与实践
Deep understanding of JVM (VI) -- garbage collection (III)
5g business is officially commercial. What are the opportunities for radio and television?
Inventory in the first half of 2022: summary of major updates and technical points of 20+ mainstream databases
MIT科技评论2022年35岁以下创新者名单发布,含AlphaFold作者等
墨天轮沙龙 | 清华乔嘉林:Apache IoTDB,源于清华,建设开源生态之路
[zero basic IOT pwn] environment construction
Six photos vous montrent pourquoi TCP serre la main trois fois?
每日面试1题-蓝队基础面试题-应急响应(1)应急响应基本思路流程+Windows入侵排查思路
Nft: unlimited possibilities to open the era of encryption Art
The secondary menu of the magic article system v5.4.0 supports the optimization of form display
Generate confrontation network, from dcgan to stylegan, pixel2pixel, face generation and image translation.
DeFi借贷协议机制对比:Euler、Compound、Aave和Rari Capital
【架构】1366- 如何画出一张优秀的架构图
Analysis on the construction scheme and necessity of constructing expressway video monitoring platform
Several points in MySQL that are easy to ignore and forget