Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
09883fef
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6388
Star
110
Fork
186
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
24
列表
看板
标记
里程碑
合并请求
2
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
24
Issue
24
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
09883fef
编写于
7月 05, 2023
作者:
DCloud-yinjiacheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更新web-view示例
上级
35f3dbfb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
10 addition
and
10 deletion
+10
-10
pages/component/web-view-local/web-view-local.uvue
pages/component/web-view-local/web-view-local.uvue
+5
-5
pages/component/web-view/web-view.uvue
pages/component/web-view/web-view.uvue
+5
-5
未找到文件。
pages/component/web-view-local/web-view-local.uvue
浏览文件 @
09883fef
<template>
<template>
<view class="uni-flex-item">
<view class="uni-flex-item">
<web-view ref="web-view" class="uni-flex-item" src="/hybrid/html/local.html" @
onPostMessage="onPostMessage
"
<web-view ref="web-view" class="uni-flex-item" src="/hybrid/html/local.html" @
message="message" @error="error
"
@
error="error" @
loading="loading" @loaded="loaded">
@loading="loading" @loaded="loaded">
</web-view>
</web-view>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-btn-v">
<view class="uni-btn-v">
...
@@ -21,7 +21,6 @@
...
@@ -21,7 +21,6 @@
</template>
</template>
<script>
<script>
import JSONObject from 'com.alibaba.fastjson.JSONObject';
export default {
export default {
data() {
data() {
return {
return {
...
@@ -41,9 +40,10 @@
...
@@ -41,9 +40,10 @@
stop() {
stop() {
(this.$refs['web-view'] as IWebViewNode).stop();
(this.$refs['web-view'] as IWebViewNode).stop();
},
},
onPostMessage(event: WebViewPost
MessageEvent) {
message(event: WebView
MessageEvent) {
console.log(JSON.stringify(event.detail));
console.log(JSON.stringify(event.detail));
const data = event.detail.data as JSONObject;
const data = event.detail.data;
if (data == null) return;
switch (data['action']) {
switch (data['action']) {
case 'navigateTo':
case 'navigateTo':
uni.navigateTo({
uni.navigateTo({
...
...
pages/component/web-view/web-view.uvue
浏览文件 @
09883fef
<template>
<template>
<view class="uni-flex-item">
<view class="uni-flex-item">
<web-view ref="web-view" class="uni-flex-item" :src="src" :webview-styles="webview_styles"
<web-view ref="web-view" class="uni-flex-item" :src="src" :webview-styles="webview_styles"
@message="message"
@
onPostMessage="onPostMessage" @
error="error" @loading="loading" @loaded="loaded">
@error="error" @loading="loading" @loaded="loaded">
</web-view>
</web-view>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-btn-v">
<view class="uni-btn-v">
...
@@ -21,7 +21,6 @@
...
@@ -21,7 +21,6 @@
</template>
</template>
<script>
<script>
import JSONObject from 'com.alibaba.fastjson.JSONObject';
export default {
export default {
data() {
data() {
return {
return {
...
@@ -46,9 +45,10 @@
...
@@ -46,9 +45,10 @@
stop() {
stop() {
(this.$refs['web-view'] as IWebViewNode).stop();
(this.$refs['web-view'] as IWebViewNode).stop();
},
},
onPostMessage(event: WebViewPost
MessageEvent) {
message(event: WebView
MessageEvent) {
console.log(JSON.stringify(event.detail));
console.log(JSON.stringify(event.detail));
const data = event.detail.data as JSONObject;
const data = event.detail.data;
if (data == null) return;
switch (data['action']) {
switch (data['action']) {
case 'navigateTo':
case 'navigateTo':
uni.navigateTo({
uni.navigateTo({
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录