当前位置:网站首页>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); }});边栏推荐
- Partition marble (multiple knapsack + binary optimization)
- How to write a technical proposal
- Inventory in the first half of 2022: summary of major updates and technical points of 20+ mainstream databases
- Distributed machine learning: model average Ma and elastic average easgd (pyspark)
- MySQL之零碎知识点
- Flutter custom component
- Animesr: learnable degradation operator and new real world animation VSR dataset
- Simulation of campus network design based on ENSP
- 6 張圖帶你搞懂 TCP 為什麼是三次握手?
- Canvas mouse control gravity JS effect
猜你喜欢

5g has been in business for three years. Where will innovation go in the future?

Horizontal visual error effect JS special effect code

Deep understanding of JVM (I) - memory structure (I)

Deep understanding of JVM (III) - memory structure (III)

每日面试1题-如何防止CDN防护被绕过

巴比特 | 元宇宙每日必读:未成年人打赏后要求退款,虚拟主播称自己是大冤种,怎么看待这个监管漏洞?...

Solution: STM32 failed to parse data using cjson

元宇宙带来的游戏变革会是怎样的?

Canvas cloud shape animation

Php8.0 environment detailed installation tutorial
随机推荐
【机器学习】K-means聚类分析
4年工作经验,多线程间的5种通信方式都说不出来,你敢信?
NFT: 开启加密艺术时代的无限可能
Redis (III) - transaction
Development details of NFT casting trading platform
阿里云ECS导入本地,解决部署的问题
Thinking on large file processing (upload, download)
[零基础学IoT Pwn] 环境搭建
Distributed machine learning: model average Ma and elastic average easgd (pyspark)
[sword finger offer] 53 - I. find the number I in the sorted array
Compile and generate busybox file system
leetcode:787. The cheapest transfer flight in station K [k-step shortest path + DFS memory + defaultdict (dict)]
[machine learning] K-means clustering analysis
Redis (VII) - sentry
Building a basic buildreoot file system
Splitting. JS text title slow loading JS effect
Servlet operation principle_ API details_ Advanced path of request response construction (servlet_2)
Mo Tianlun salon | Tsinghua qiaojialin: Apache iotdb, originated from Tsinghua, is building an open source ecological road
基于SSH的网上商城设计
MySQL之零碎知识点