Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
b853da18
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5995
Star
90
Fork
162
代码
文件
提交
分支
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看板
提交
b853da18
编写于
9月 08, 2023
作者:
雪洛
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: add import object demo
上级
4bee2279
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
172 addition
and
1 deletion
+172
-1
pages.json
pages.json
+6
-0
pages/API/call-function/call-function.uvue
pages/API/call-function/call-function.uvue
+1
-1
pages/API/import-object/import-object.uvue
pages/API/import-object/import-object.uvue
+116
-0
pages/tabBar/API.uvue
pages/tabBar/API.uvue
+4
-0
uniCloud-aliyun/cloudfunctions/todo/index.obj.js
uniCloud-aliyun/cloudfunctions/todo/index.obj.js
+39
-0
uniCloud-aliyun/cloudfunctions/todo/package.json
uniCloud-aliyun/cloudfunctions/todo/package.json
+6
-0
未找到文件。
pages.json
浏览文件 @
b853da18
...
...
@@ -672,6 +672,12 @@
"navigationBarTitleText"
:
""
}
},
{
"path"
:
"pages/API/import-object/import-object"
,
"style"
:
{
"navigationBarTitleText"
:
""
}
},
{
"path"
:
"pages/API/get-system-info/get-system-info"
,
"style"
:
{
...
...
pages/API/call-function/call-function.uvue
浏览文件 @
b853da18
...
...
@@ -18,7 +18,7 @@
export default {
data() {
return {
title: '
uniCloud.callFunction
'
title: '
请求云函数
'
}
},
onLoad() {
...
...
pages/API/import-object/import-object.uvue
0 → 100644
浏览文件 @
b853da18
<template>
<!-- #ifdef APP -->
<scroll-view style="flex:1">
<!-- #endif -->
<view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-btn-v uni-common-mt">
<button type="primary" @tap="addTodo">添加Todo</button>
</view>
<view class="uni-btn-v uni-common-mt">
<button type="primary" @tap="randomFail">随机触发失败重试</button>
</view>
<view class="uni-btn-v uni-common-mt">
<button type="primary" @tap="fail">云对象失败调用</button>
</view>
<view class="uni-btn-v uni-common-mt">
<button type="primary" @tap="success">云对象成功调用</button>
</view>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
export default {
data() {
return {
title: '请求云对象'
}
},
methods: {
addTodo() {
const todo = uniCloud.importObject('todo')
const title = '学习编程'
const content = '熟悉uts语法'
todo.add(title, content).then<void>((res: UTSJSONObject) : void => {
uni.showModal({
title: '错误',
content: res['showMessage'] as string,
showCancel: false
})
}).catch<void>((err : any | null) : void => {
const error = err as UniCloudError
uni.showModal({
title: '错误',
content: error.errMsg,
showCancel: false
})
})
},
randomFail() {
const todoObj = uniCloud.importObject('todo', {
errorOptions: {
retry: true
}
})
todoObj.randomFail().then<void>((res: UTSJSONObject) : void => {
uni.showModal({
title: '错误',
content: res['showMessage'] as string,
showCancel: false
})
}).catch<void>((err : any | null) : void => {
const error = err as UniCloudError
uni.showModal({
title: '错误',
content: error.errMsg,
showCancel: false
})
})
},
fail() {
const todo = uniCloud.importObject('todo')
todo.fail().then<void>((res: UTSJSONObject) : void => {
uni.showModal({
title: '错误',
content: 'todo.fail应调用失败,此处错误的触发了成功回调',
showCancel: false
})
console.log('todo.fail: ', res);
}).catch<void>((err : any | null) : void => {
const error = err as UniCloudError
uni.showModal({
title: '错误',
content: error.errMsg,
showCancel: false
})
})
},
success() {
const todo = uniCloud.importObject('todo')
todo.success().then<void>((res: UTSJSONObject) : void => {
uni.showModal({
title: '错误',
content: res['showMessage'] as string,
showCancel: false
})
}).catch<void>((err : any | null) : void => {
const error = err as UniCloudError
uni.showModal({
title: '错误',
content: error.errMsg,
showCancel: false
})
})
}
}
}
</script>
<style>
</style>
pages/tabBar/API.uvue
浏览文件 @
b853da18
...
...
@@ -385,6 +385,10 @@
name: '云函数',
url: 'call-function',
},
{
name: '云对象',
url: 'import-object',
},
] as Page[],
},
/* {
...
...
uniCloud-aliyun/cloudfunctions/todo/index.obj.js
0 → 100644
浏览文件 @
b853da18
// 云对象教程: https://uniapp.dcloud.net.cn/uniCloud/cloud-obj
// jsdoc语法提示教程:https://ask.dcloud.net.cn/docs/#//ask.dcloud.net.cn/article/129
module
.
exports
=
{
async
add
(
title
,
content
)
{
console
.
log
(
title
,
content
)
return
{
showMessage
:
`Todo added, title:
${
title
}
, content:
${
content
}
`
}
},
async
randomFail
()
{
const
random
=
Math
.
random
()
console
.
log
(
random
);
if
(
random
>
0.5
)
{
return
{
errCode
:
'
RANDOM_FAIL
'
,
errMsg
:
'
todo.randomFail failed
'
}
}
else
{
return
{
errCode
:
0
,
errMsg
:
''
,
showMessage
:
'
todo.randomFail successed
'
}
}
},
async
fail
()
{
return
{
errCode
:
'
TEST_ERROR_CODE
'
,
errMsg
:
'
todo.fail failed
'
,
}
},
async
success
()
{
return
{
errCode
:
0
,
errMsg
:
''
,
showMessage
:
'
todo.success successed
'
}
}
}
uniCloud-aliyun/cloudfunctions/todo/package.json
0 → 100644
浏览文件 @
b853da18
{
"name"
:
"todo"
,
"dependencies"
:
{},
"extensions"
:
{
}
}
\ No newline at end of file
雪洛
@u013082782
mentioned in commit
a1f34f14
·
9月 08, 2023
mentioned in commit
a1f34f14
mentioned in commit a1f34f14ecef8185bea48e50429855133c673e9a
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录