uniCloud云函数创建与调用

创建云函数say()

module.exports = {
	_before: function () { // 通用预处理器

	},

	say(message){
		return {
			errorCode: 0,
			data: "Hello I'm uniCloud!"+message
		}
	}
}

调用云函数say()

	export default {
		data() {
			return {
				href: 'https://uniapp.dcloud.io/component/README?id=uniui'
			}
		},
		methods: {
			async callco(){//异步调用
				const co1 = uniCloud.importObject("co1")//导入云函数
				let res = await co1.say("Hello world!~")//调用
				uni.showModal({
					content:JSON.stringify(res),
					showCancel:false
				})
				
			}

		}
	}
<template>
	<view class="container">		
		<button @click="callco">呼叫服务器</button>		
	</view>
</template>