Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
e0a41a90
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6006
Star
91
Fork
164
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
e0a41a90
编写于
11月 09, 2023
作者:
taohebin@dcloud.io
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 部分页面回调改为箭头函数方式
上级
56ec9a7b
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
98 addition
and
98 deletion
+98
-98
pages/API/download-file/download-file.uvue
pages/API/download-file/download-file.uvue
+74
-74
pages/API/request/request.uvue
pages/API/request/request.uvue
+6
-6
pages/API/websocket-global/websocket-global.uvue
pages/API/websocket-global/websocket-global.uvue
+8
-8
pages/API/websocket-socketTask/websocket-socketTask.uvue
pages/API/websocket-socketTask/websocket-socketTask.uvue
+10
-10
未找到文件。
pages/API/download-file/download-file.uvue
浏览文件 @
e0a41a90
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
<!-- #endif -->
<!-- #endif -->
</template>
</template>
<script>
<script>
export default {
export default {
data() {
data() {
return {
return {
title: 'downloadFile',
title: 'downloadFile',
...
@@ -42,14 +42,14 @@ export default {
...
@@ -42,14 +42,14 @@ export default {
this.task?.abort();
this.task?.abort();
},
},
methods: {
methods: {
downloadImage: function
() {
downloadImage: function
() {
uni.showLoading({
uni.showLoading({
title: '下载中'
title: '下载中'
})
})
var self = this
var self = this
this.task = uni.downloadFile({
this.task = uni.downloadFile({
url: "https://web-assets.dcloud.net.cn/unidoc/zh/uni-app.png",
url: "https://web-assets.dcloud.net.cn/unidoc/zh/uni-app.png",
success(res)
{
success: (res) =>
{
if (this.pageVisible) {
if (this.pageVisible) {
console.log('downloadFile success, res is', res)
console.log('downloadFile success, res is', res)
self.imageSrc = res.tempFilePath;
self.imageSrc = res.tempFilePath;
...
@@ -70,10 +70,10 @@ export default {
...
@@ -70,10 +70,10 @@ export default {
})
})
},
},
//自动化测试例专用
//自动化测试例专用
jest_downloadFile(){
jest_downloadFile() {
uni.downloadFile({
uni.downloadFile({
url: "https://web-assets.dcloud.net.cn/unidoc/zh/uni-app.png",
url: "https://web-assets.dcloud.net.cn/unidoc/zh/uni-app.png",
success() {
success: () => {
this.jest_result = true
this.jest_result = true
},
},
fail: () => {
fail: () => {
...
@@ -82,19 +82,19 @@ export default {
...
@@ -82,19 +82,19 @@ export default {
});
});
}
}
}
}
}
}
</script>
</script>
<style>
<style>
.img {
.img {
width: 500rpx;
width: 500rpx;
height: 500rpx;
height: 500rpx;
margin: 0 auto;
margin: 0 auto;
}
}
.image-container {
.image-container {
display: flex;
display: flex;
justify-content: center;
justify-content: center;
align-items: center;
align-items: center;
}
}
</style>
</style>
\ No newline at end of file
pages/API/request/request.uvue
浏览文件 @
e0a41a90
...
@@ -190,7 +190,7 @@
...
@@ -190,7 +190,7 @@
sslVerify: false,
sslVerify: false,
withCredentials: false,
withCredentials: false,
firstIpv4: false,
firstIpv4: false,
success
(res)
{
success
: (res) =>
{
if (this.pageVisible) {
if (this.pageVisible) {
console.log('request success', JSON.stringify(res.data))
console.log('request success', JSON.stringify(res.data))
uni.showToast({
uni.showToast({
...
@@ -202,7 +202,7 @@
...
@@ -202,7 +202,7 @@
this.res = '请求结果 : ' + JSON.stringify(res);
this.res = '请求结果 : ' + JSON.stringify(res);
}
}
},
},
fail
(err)
{
fail
: (err) =>
{
if (this.pageVisible) {
if (this.pageVisible) {
console.log('request fail', err);
console.log('request fail', err);
uni.showModal({
uni.showModal({
...
@@ -211,7 +211,7 @@
...
@@ -211,7 +211,7 @@
});
});
}
}
},
},
complete
()
{
complete
: () =>
{
uni.hideLoading()
uni.hideLoading()
},
},
});
});
...
@@ -229,10 +229,10 @@
...
@@ -229,10 +229,10 @@
sslVerify: false,
sslVerify: false,
withCredentials: false,
withCredentials: false,
firstIpv4: false,
firstIpv4: false,
success
()
{
success
: () =>
{
this.jest_result = true;
this.jest_result = true;
},
},
fail
()
{
fail
: () =>
{
this.jest_result = false;
this.jest_result = false;
},
},
});
});
...
...
pages/API/websocket-global/websocket-global.uvue
浏览文件 @
e0a41a90
...
@@ -60,10 +60,10 @@ export default {
...
@@ -60,10 +60,10 @@ export default {
uni.closeSocket({
uni.closeSocket({
code: 1000,
code: 1000,
reason: 'close reason from client',
reason: 'close reason from client',
success
(res: any)
{
success
:(res: any) =>
{
console.log('uni.closeSocket success', res)
console.log('uni.closeSocket success', res)
},
},
fail
(err: any)
{
fail
:(err: any) =>
{
console.log('uni.closeSocket fail', err)
console.log('uni.closeSocket fail', err)
},
},
} as CloseSocketOptions)
} as CloseSocketOptions)
...
@@ -84,11 +84,11 @@ export default {
...
@@ -84,11 +84,11 @@ export default {
})
})
uni.connectSocket({
uni.connectSocket({
url: 'ws://websocket.dcloud.net.cn',
url: 'ws://websocket.dcloud.net.cn',
success
(res: any)
{
success
:(res: any) =>
{
// 这里是接口调用成功的回调,不是连接成功的回调,请注意
// 这里是接口调用成功的回调,不是连接成功的回调,请注意
console.log('uni.connectSocket success', res)
console.log('uni.connectSocket success', res)
},
},
fail
(err: any)
{
fail
:(err: any) =>
{
// 这里是接口调用失败的回调,不是连接失败的回调,请注意
// 这里是接口调用失败的回调,不是连接失败的回调,请注意
console.log('uni.connectSocket fail', err)
console.log('uni.connectSocket fail', err)
},
},
...
@@ -140,10 +140,10 @@ export default {
...
@@ -140,10 +140,10 @@ export default {
this.platform +
this.platform +
' : ' +
' : ' +
parseInt((Math.random() * 10000).toString()).toString(),
parseInt((Math.random() * 10000).toString()).toString(),
success
(res: any)
{
success
:(res: any) =>
{
console.log(res)
console.log(res)
},
},
fail
(err: any)
{
fail
:(err: any) =>
{
console.log(err)
console.log(err)
},
},
} as SendSocketMessageOptions)
} as SendSocketMessageOptions)
...
@@ -152,10 +152,10 @@ export default {
...
@@ -152,10 +152,10 @@ export default {
uni.closeSocket({
uni.closeSocket({
code: 1000,
code: 1000,
reason: 'close reason from client',
reason: 'close reason from client',
success
(res: any)
{
success
:(res: any) =>
{
console.log('uni.closeSocket success', res)
console.log('uni.closeSocket success', res)
},
},
fail
(err: any)
{
fail
:(err: any) =>
{
console.log('uni.closeSocket fail', err)
console.log('uni.closeSocket fail', err)
},
},
} as CloseSocketOptions)
} as CloseSocketOptions)
...
...
pages/API/websocket-socketTask/websocket-socketTask.uvue
浏览文件 @
e0a41a90
...
@@ -65,10 +65,10 @@ export default {
...
@@ -65,10 +65,10 @@ export default {
task.close({
task.close({
code: 1000,
code: 1000,
reason: 'close reason from client',
reason: 'close reason from client',
success
(res: any)
{
success
:(res: any) =>
{
console.log('uni.closeSocket success', res)
console.log('uni.closeSocket success', res)
},
},
fail
(err: any)
{
fail
:(err: any) =>
{
console.log('uni.closeSocket fail', err)
console.log('uni.closeSocket fail', err)
},
},
} as CloseSocketOptions)
} as CloseSocketOptions)
...
@@ -89,11 +89,11 @@ export default {
...
@@ -89,11 +89,11 @@ export default {
})
})
this.socketTask = uni.connectSocket({
this.socketTask = uni.connectSocket({
url: 'ws://websocket.dcloud.net.cn',
url: 'ws://websocket.dcloud.net.cn',
success
(res: any)
{
success
:(res: any) =>
{
// 这里是接口调用成功的回调,不是连接成功的回调,请注意
// 这里是接口调用成功的回调,不是连接成功的回调,请注意
console.log('uni.connectSocket success', res)
console.log('uni.connectSocket success', res)
},
},
fail
(err: any)
{
fail
:(err: any) =>
{
// 这里是接口调用失败的回调,不是连接失败的回调,请注意
// 这里是接口调用失败的回调,不是连接失败的回调,请注意
console.log('uni.connectSocket fail', err)
console.log('uni.connectSocket fail', err)
},
},
...
@@ -145,10 +145,10 @@ export default {
...
@@ -145,10 +145,10 @@ export default {
parseInt(Math.random() * 10000 + '').toString()
parseInt(Math.random() * 10000 + '').toString()
this.socketTask?.send({
this.socketTask?.send({
data,
data,
success
(res: any)
{
success
:(res: any) =>
{
console.log(res)
console.log(res)
},
},
fail
(err: any)
{
fail
:(err: any) =>
{
console.log(err)
console.log(err)
},
},
} as SendSocketMessageOptions)
} as SendSocketMessageOptions)
...
@@ -157,10 +157,10 @@ export default {
...
@@ -157,10 +157,10 @@ export default {
this.socketTask?.close({
this.socketTask?.close({
code: 1000,
code: 1000,
reason: 'close reason from client',
reason: 'close reason from client',
success
(res: any)
{
success
:(res: any) =>
{
console.log('uni.closeSocket success', res)
console.log('uni.closeSocket success', res)
},
},
fail
(err: any)
{
fail
:(err: any) =>
{
console.log('uni.closeSocket fail', err)
console.log('uni.closeSocket fail', err)
},
},
} as CloseSocketOptions)
} as CloseSocketOptions)
...
@@ -184,10 +184,10 @@ export default {
...
@@ -184,10 +184,10 @@ export default {
parseInt(Math.random() * 10000 + '').toString()
parseInt(Math.random() * 10000 + '').toString()
this.socketTask?.send({
this.socketTask?.send({
data,
data,
success
(_)
{
success
:(_) =>
{
this.jest_result++
this.jest_result++
},
},
fail
(_)
{
fail
:(_) =>
{
this.jest_result = 0
this.jest_result = 0
},
},
} as SendSocketMessageOptions)
} as SendSocketMessageOptions)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录