当前位置:网站首页>uniCloud use
uniCloud use
2022-08-02 04:34:00 【GentleTK】
uni-appYes is a use Vue.js 开发所有前端应用的框架,开发者编写一套代码,可发布到iOS、Android、Web(响应式)、以及各种小程序(微信/支付宝/百度/头条/QQ/钉钉/淘宝)、快应用等多个平台.
1 创建uni-app项目
在 HBuilder 选择文件,新建(如果提示需要安装插件,按照提示安装即可,稍后会要求登陆,如果没有 HBuilder 账户,可以根据提示去注册):


2 创建云服务空间
在 uniCloud 目录上单击右键,选择打开 uniCloud Web 控制台,根据提示创建云服务空间:

3 关联云服务空间
在 uniCloud 目录上单击右键,选择 关联云服务空间或项目,选择刚刚创建好的云服务空间:

4 新建云函数
在 uniCloud/cloudfunctions 目录上单击右键,Choose New Cloud Function:

Edit the cloud function content as follows:
'use strict';
exports.main = async (event, context) => {
return "hello uni-app!"
};
5 Run cloud functions locally
CTRL+R,选择 Run cloud functions locally(If prompted to install the plugin,Install it according to the prompts,If the prompt parameter is incorrect,可以点击manifest.json,看是否有appid,如果没有,Then get it againappid):

6 Upload to the cloud and run
在 uniCloud/cloudfunctions/test 目录上单击右键,选择上传并运行:

可以在webView uploaded cloud functions in the console:

修改 pages/index/index.vue :
<template>
<view class="content">
<image class="logo" src="/static/logo.png"></image>
<view class="text-area">
<text class="title">{
{title}}</text>
</view>
</view>
</template>
<script>
export default {
data() {
return {
title: 'Hello'
}
},
onLoad() {
uniCloud.callFunction({
name:"test",
success: (e) => {
this.title = e
}
})
},
methods: {
}
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
</style>
运行到内置浏览器(If prompted to install the plugin,按照提示安装即可):

uni.callFunction 的好处:
- 更安全,No hacking can be foundURL入口.
- 无需URL,i.e. no domain name required,if only doAPP和小程序,There is no need to purchase and register a domain name.
- 自带
uni-id的token.
边栏推荐
猜你喜欢

深度学习理论:model.fit 函数参数详解

zsh: command not found: xxx 解决方法

uniCloud使用

GM8775C规格书,MIPI转LVDS,MIPI转双路LVDS分享

【霍尔效应传感器模块与 Arduino】

Out of memory error on GPU 0. Cannot allocate xxxGB memory on GPU 0, available memory is only xxx

Arduino点亮数码管

【Popular Science Post】UART Interface Communication Protocol

D类音频功放NS4110B电路设计
![[Arduino uses a rotary encoder module]](/img/2a/43ffe782d6d5aa9f38f875bb5d98b1.png)
[Arduino uses a rotary encoder module]
随机推荐
深度学习理论:测试集与验证集的区别及各自用途
Industry where edge gateway strong?
三相同步发电机的空载短路的simulink仿真
Two-Stream Convolutional Networks for Action Recognition in Videos双流网络论文精读
[Arduino connected to GP2Y1014AU0F dust sensor]
I2C无法访问ATEC508A加密芯片问题
【Arduino 连接DHT11 湿度和温度传感器】
Website development plan research
【科普贴】UART接口通讯协议
【树莓派入门(2)树莓派的远程控制】
管理node版本的工具volta
USB HUB USB集线器电路设计
USB_ID介绍
Go 程序太大了,能要个延迟初始化不?
18张图,直观理解神经网络、流形和拓扑
【Popular Science Post】Detailed explanation of MDIO interface
深度学习理论:model.fit 函数参数详解
工业边缘网关究竟强大在哪里?
【opencv】error: (-215:Assertion failed) ssize.empty() in function ‘cv::resize‘报错原因
功率计,物联网,智能插座电路设计【毕业设计】