当前位置:网站首页>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); }});边栏推荐
- ASP. Net password encryption and password login
- ASP. Net authentication code login
- NFT: 开启加密艺术时代的无限可能
- Post MSF infiltration summary
- New research of HKUST & MsrA: about image to image conversion, finishing is all you need
- Nft: unlimited possibilities to open the era of encryption Art
- ABAP publish restful service
- 2022上半年盘点:20+主流数据库重大更新及技术要点汇总
- Analysis on the construction scheme and necessity of constructing expressway video monitoring platform
- 编译生成busybox文件系统
猜你喜欢

后渗透之文件系统+上传下载文件

5G商用三年,未来创新何去何从?

Daily interview 1 question - how to prevent CDN protection from being bypassed

Deep understanding of JVM (V) - garbage collection (II)

K-line diagram must be read for quick start

Six pictures show you why TCP has three handshakes?

Conception d'un centre commercial en ligne basé sur SSH

What will be the game changes brought about by the meta universe?

Tubes响应性数据系统的设计与原理
![[Netease Yunxin] playback demo build: unable to convert parameter 1 from](/img/6e/41e1eafd4c863c9e5f3a545b69a257.png)
[Netease Yunxin] playback demo build: unable to convert parameter 1 from "asyncmodalrunner *" to "std:: nullptr\u T"**
随机推荐
编译生成busybox文件系统
IEEE TBD SCI影响因子提升至4.271,位列Q1区!
清华只能排第3?2022软科中国大学AI专业排名发布
Do fresh students get a job or choose a job after graduation?
New research of HKUST & MsrA: about image to image conversion, finishing is all you need
2022上半年盘点:20+主流数据库重大更新及技术要点汇总
零基础也能做Apple大片!这款免费工具帮你渲染、做特效、丝滑展示
元宇宙带来的游戏变革会是怎样的?
[bjdctf2020]the mystery of ip|[ciscn2019 southeast China division]web11|ssti injection
Six photos vous montrent pourquoi TCP serre la main trois fois?
Ardunio esp32 obtains real-time temperature and humidity in mqtt protocol (DH11)
Booking UI effect implemented by svg
构建基本buildroot文件系统
K-line diagram must be read for quick start
应届生毕业之后先就业还是先择业?
Post penetration file system + uploading and downloading files
Several points in MySQL that are easy to ignore and forget
5g business is officially commercial. What are the opportunities for radio and television?
Redis (VII) - sentry
Communication network electronic billing system based on SSH