提交 3834c04f 编写于 作者: 雪洛's avatar 雪洛

feat: add cloudfunction demo

上级 75cd33b9
......@@ -55,24 +55,24 @@
"style": {
"navigationBarTitleText": "radio"
}
},
{
"path": "pages/component/rich-text/rich-text",
"style": {
"navigationBarTitleText": "rich-text"
}
},
{
"path": "pages/component/rich-text/rich-text-tags",
"style": {
"navigationBarTitleText": "rich-text-tags"
}
},
{
"path": "pages/component/rich-text/rich-text-complex",
"style": {
"navigationBarTitleText": "rich-text-complex"
}
},
{
"path": "pages/component/rich-text/rich-text",
"style": {
"navigationBarTitleText": "rich-text"
}
},
{
"path": "pages/component/rich-text/rich-text-tags",
"style": {
"navigationBarTitleText": "rich-text-tags"
}
},
{
"path": "pages/component/rich-text/rich-text-complex",
"style": {
"navigationBarTitleText": "rich-text-complex"
}
},
{
"path": "pages/component/checkbox/checkbox",
......@@ -660,6 +660,12 @@
"navigationBarTitleText": ""
}
},
{
"path": "pages/API/call-function/call-function",
"style": {
"navigationBarTitleText": ""
}
},
{
"path": "pages/API/get-system-info/get-system-info",
"style": {
......@@ -767,12 +773,12 @@
"style": {
"navigationBarTitleText": "swiper-list"
}
},
{
"path": "pages/template/swiper-list2/swiper-list2",
"style": {
"navigationBarTitleText": "swiper-list2"
}
},
{
"path": "pages/template/swiper-list2/swiper-list2",
"style": {
"navigationBarTitleText": "swiper-list2"
}
},
{
"path": "pages/template/swiper-vertical-video/swiper-vertical-video",
......@@ -832,7 +838,7 @@
{
"path": "pages/template/long-list/long-list",
"style": {
"navigationBarTitleText": "复杂长列表",
"navigationBarTitleText": "复杂长列表",
"enablePullDownRefresh": true
}
},
......@@ -859,7 +865,7 @@
"style": {
"navigationBarTitleText": "自定义下拉刷新的scroll-view属性示例"
}
},
},
{
"path": "pages/template/pull-zoom-image/pull-zoom-image",
"style": {
......
<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" @click="callFunction">请求云函数</button>
</view>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
export default {
data() {
return {
title: 'uniCloud.callFunction'
}
},
onLoad() {
},
onUnload() {
},
methods: {
callFunction: function () {
uni.showLoading({
title: '加载中...'
})
uniCloud.callFunction({
name: 'echo-cf',
data: {
num: 1,
str: 'ABC'
} as UTSJSONObject
}).then<void>(res => {
const result = res.result
console.log(JSON.stringify(result))
uni.hideLoading()
uni.showModal({
title: '提示',
content: result['showMessage'] as string,
showCancel: false
})
}).catch<void>((err: UniCloudError) => {
uni.hideLoading()
uni.showModal({
title: '错误',
content: err.errMsg,
showCancel: false
})
})
}
}
}
</script>
<style>
</style>
......@@ -157,6 +157,10 @@
name: '全局websocket',
url: 'websocket-global',
api: ["connectSocket", "onSocketOpen", "onSocketError", "sendSocketMessage", "onSocketMessage", "closeSocket", "onSocketClose"]
},
{
name: '请求云函数',
url: 'call-function',
},
] as Page[],
},
......
'use strict';
exports.main = async (event, context) => {
//event为客户端上传的参数
console.log('event : ', event)
//返回数据给客户端
return {
event,
context,
showMessage: 'Hello uniCloud function'
}
};
{
"name": "echo-cf",
"dependencies": {},
"extensions": {}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册