当前位置: 首页 > wzjs >正文

网站备案是否收费游戏代理加盟

网站备案是否收费,游戏代理加盟,做网站面临的困难,网店装修素材网站完成云侧云函数开发、调试、部署之后,接下来就是端侧调用云函数获取数据,实现真正意义上的端云协同开发。 1、设置云函数配置项 端侧调用云函数需要网络环境,因此,需要在“entry/src/main/module.json5”文件中添加网络权限。 …

完成云侧云函数开发、调试、部署之后,接下来就是端侧调用云函数获取数据,实现真正意义上的端云协同开发。

1、设置云函数配置项

端侧调用云函数需要网络环境,因此,需要在“entry/src/main/module.json5”文件中添加网络权限。

"requestPermissions": [{"name": "ohos.permission.INTERNET"}
]

2、查看函数名和版本

在函数的触发器页面点击“HTTP触发器”,查看“触发URL”的后缀,获取触发器的标识,格式为“函数名-版本号”。如下图所示,“calculate-baby-age-$latest”即为HTTP触发器标识,其中“calculate-baby-age”为函数名,“$latest”为版本号。

image-20250622214613220

3、端侧调用云函数

在端侧工程(Application)模块entry目录下打开src/main/ets/pages > Index.ets页面使用使用搜索框组件Search和日期弹窗CalendarPickerDialog实现宝宝出生日期选择,并根据选择的日期调用计算宝宝的年龄云函数返回包含年、月、日、天数的宝宝年龄信息,具体调用云函数步骤如下所示:

1)在项目中导入云函数组件cloudFunction。

import type { BusinessError } from '@kit.BasicServicesKit';
import { cloudFunction } from '@kit.CloudFoundationKit';

2)调用call()方法设置函数,在方法中传入函数名称,返回调用结果。

// Promise异步回调
function callFunctionPromise() {cloudFunction.call({name: 'calculate-baby-age', // functionName需替换成指定的函数名version: '$latest',   // 如果不传入版本号,默认为“$latest”。timeout: 10 * 1000,   // 单位为毫秒,默认为70*1000毫秒。data: {               // data为云函数接收的入参birthday: '2023-3-15'}}).then((value: cloudFunction.FunctionResult) => {hilog.info(0x0000, 'testTag', `Succeeded in calling the function, result: ${JSON.stringify(value.result)}`);}).catch((err: BusinessError) => {hilog.error(0x0000, 'testTag', `Failed to call the function, code: ${err.code}, message: ${err.message}`);});
}// callback异步调用
function callFunctionCallback() {cloudFunction.call({name: 'calculate-baby-age',version: '$latest',timeout: 10 * 1000,data: {birthday: '2023-3-15'}}, (err: BusinessError, value: cloudFunction.FunctionResult) => {if (err) {hilog.error(0x0000, 'testTag', `Failed to call the function, code: ${err.code}, message: ${err.message}`);return;}hilog.info(0x0000, 'testTag', `Succeeded in calling the function, result: ${JSON.stringify(value.result)}`);});
}

3)如果需要关注函数的返回值,可调用result属性获取。

let resultValue = value.result;

4、完整代码

import type { BusinessError } from '@kit.BasicServicesKit';
import { cloudFunction } from '@kit.CloudFoundationKit';interface BabyAge {years: number;months: number;days: number;totalDays: number;
}interface ResponseBody {code: number;desc: string;data: BabyAge
}@Entry
@Component
struct Index {controller: SearchController = new SearchController();@State birthday: string = "";@State callFunctionResult: BabyAge | undefined = undefined;build() {Column({ space: 10 }) {Search({ controller: this.controller, value: this.birthday }).width('90%').height('54vp').searchIcon(new SymbolGlyphModifier($r('sys.symbol.calendar_badge_play')).fontColor([Color.Blue]).fontSize('30fp')).cancelButton({style: CancelButtonStyle.INVISIBLE}).borderRadius('8vp').onClick(() => {CalendarPickerDialog.show({selected: new Date(this.birthday),acceptButtonStyle: {style: ButtonStyleMode.EMPHASIZED},cancelButtonStyle: {fontColor: Color.Grey},onAccept: async (value) => {console.info("calendar onAccept:" + JSON.stringify(value))let result: cloudFunction.FunctionResult = await cloudFunction.call({name: 'calculate-baby-age',version: '$latest',timeout: 10 * 1000,data: {birthday: value}});let body = result.result as ResponseBody;this.callFunctionResult = body.data;}})})if (this.callFunctionResult !== undefined) {Text(`我已经${this.callFunctionResult.years}岁了 ${this.callFunctionResult.months}${this.callFunctionResult.days}天了~`)Text(`我已经出生${this.callFunctionResult.totalDays}天了~`)}}.width('100%').height('100%')}
}

文章转载自:

http://Svy8dIrE.rhkmn.cn
http://R32gpSPS.rhkmn.cn
http://cfV8EanV.rhkmn.cn
http://WhrXaZE9.rhkmn.cn
http://I1ZfjAu0.rhkmn.cn
http://IWSRGBoC.rhkmn.cn
http://8Hw7rkzV.rhkmn.cn
http://CuG9t8TG.rhkmn.cn
http://iidmigWi.rhkmn.cn
http://GQg2S8N9.rhkmn.cn
http://mPVUJmnf.rhkmn.cn
http://OSHSpVjj.rhkmn.cn
http://K4npZynd.rhkmn.cn
http://dRFNfe5Q.rhkmn.cn
http://ehmiZhDa.rhkmn.cn
http://7DZe70Zp.rhkmn.cn
http://RIP8z7V5.rhkmn.cn
http://sFsuUOYo.rhkmn.cn
http://8wWtkEE9.rhkmn.cn
http://8K5sP5iC.rhkmn.cn
http://D23D4pPn.rhkmn.cn
http://G1DWe2aC.rhkmn.cn
http://FbOZpwxT.rhkmn.cn
http://NQwfQCUK.rhkmn.cn
http://Gnvh274U.rhkmn.cn
http://PUw7aGHC.rhkmn.cn
http://13bP6hvP.rhkmn.cn
http://qUVWdbYA.rhkmn.cn
http://HwURb3js.rhkmn.cn
http://DYIm0QLa.rhkmn.cn
http://www.dtcms.com/wzjs/672203.html

相关文章:

  • 上海高端网站搭建协会建设网站的必要性
  • 投稿的网站做网站很简单
  • 分类信息建站系统优秀设计网站推荐
  • 青岛百度网站排名推荐一下做图文的网站
  • 江门网站建设公司哪家好网站开发就业怎么样
  • 如何建立购物网站宁波网站优化找哪家
  • 网站开发专业有什么工作中国建设官网首页
  • 企业 北京 响应式网站巨量算数关键词查询
  • 怎样做百度推广网站鹤壁市城乡一体化示范区规划图
  • wordpress站点取名制作公司网站需要购买域名和服务器吗
  • 做抛物线的网站wordpress自定义404页面
  • 网站导航下拉菜单代码电商网站设计趋势
  • 怎样用网站模板做网站章丘市网站建设seo
  • 衡阳网站建设在中国可以做国外的域名网站吗
  • 什么样的企业要做网站做企业官网费用
  • 发果怎么做视频网站网站开发培训要多少钱
  • 网站用户 分析网站销售系统怎么做
  • 福建自己建设网站新闻发布会主持词
  • 手机网站建设深圳南昌网站建设公司价位
  • 网站公司怎么找客户4399网页游戏官网
  • 企业网站模版紫金网站建设
  • 百度一下浏览器下载安装seo常见的优化技术
  • 免费的网站平台做母婴育儿类网站好做seo排名吗
  • 网站导航怎么做的淘宝上的网站建设可信
  • 网站建设中通知如何用wordpress搭建企业网站
  • 网站留言短信提醒高权重域名做网站
  • 商城型企业网站的功能dede建设网站
  • 163企业邮箱申请佛山网站优化运营
  • 购物网站欢迎页面怎么设计宁波品牌网站推广优化公司
  • 北京龙鼎网站建设公司深圳软件公司平均薪资排行榜