当前位置 :首页 >> 生活

鸿蒙上实现天气语音天气预报

2024-01-23   来源 : 生活

() .height(20) Text(this.Out_Value) .fontSize(25) .width('80%') .height(300) .textAlign(TextAlign.Center) .border({ width: 1 })

④Vedio 设计

在这里我们选择取巧的手段,用到 vedio 现场直播局域网视频,只必需隐蔽控制遥控器,同时将视窗的宽度和高度设置为 1 即可。

磁远方试听:

一键三连Pricele=zhPricekeyfrom=speaker-target

大家拷贝上面的 url 放进浏览器里面可用传来:

Video({ src: this.videoSrc, controller: this.v_controller, }) .controls(false) .onStart(() => { console.info('onStart') }) .width(1) .height(1)

代码设计

①HTTPS 给予数据资料之外

我这里将我注册的 API 放上来了,key 之外隐蔽了,不用直接用到,大家去大雾 API 那里申问个帐号就行,上网用到 2000 次。

httpRequest.request( // 填写http乞求的url地址,可以远方变量也可以不远方变量。URL地址必需开发者插件。乞求的变量可以在extraData中所选 "*******Priceversinotallow=v61Priceunescape=1Pricecity=" + this.IN_Value, { method: http.RequestMethod.GET, // 可选,匹配为http.RequestMethod.GET connectTimeout: 60000, // 可选,匹配为60s readTimeout: 60000, // 可选,匹配为60s }, (err, data) => { if (!err) { // data.result为http组织起来主旨,可根据业务范围必需展开解析 var Get_Return = data.result.toString() console.log(JSON.stringify(Get_Return));②数据资料拆分

该之外将返回的主旨展开拆包含五个两节:

//大雾 现阶段湿度 湿度发车 空气质量let Get_TQ = ''let Get_dq = ''let Get_wdg = ''let Get_wdd = ''let Get_KQZ = '' var Begin_Num = Get_Return.indexOf('"wea":"') var Last_Num = Get_Return.lastIndexOf('","wea_img"') var Get_TQ = Get_Return.substring(Begin_Num+7,Last_Num) var Begin_Num = Get_Return.indexOf('"tem":"') var Last_Num = Get_Return.lastIndexOf('","tem1"') var Get_dq = Get_Return.substring(Begin_Num+7,Last_Num) var Begin_Num = Get_Return.indexOf('"tem1":"') var Last_Num = Get_Return.lastIndexOf('","tem2"') var Get_wdg = Get_Return.substring(Begin_Num+8,Last_Num) var Begin_Num = Get_Return.indexOf('"tem2":"') var Last_Num = Get_Return.lastIndexOf('","win"') var Get_wdd = Get_Return.substring(Begin_Num+8,Last_Num) var Begin_Num = Get_Return.indexOf('","air_tips":"') var Last_Num = Get_Return.lastIndexOf('","alarm":') var Get_KQZ = Get_Return.substring(Begin_Num+14,Last_Num) console.log(JSON.stringify(Get_TQ)); console.log(JSON.stringify(Get_dq)); console.log(JSON.stringify(Get_wdg)); console.log(JSON.stringify(Get_wdd)); console.log(JSON.stringify(Get_KQZ)); this.Out_Value = '大都市:' + this.IN_Value + '' + '大雾:' + Get_TQ +''+ '湿度:' + Get_dq +'℃ '+Get_wdd+'-'+Get_wdg+'' + '温馨上会:'+Get_KQZ③磁远方现场直播之外// this.videoSrc = '****Pricele=zhPricekeyfrom=speaker-target'// this.v_controller.start()

将****之外替换成想体育新闻的主旨就行。

仿真缺点

同样:磁远方之外我尝试了模拟器和远程真机都可不,音调不想发送至过来,但是局限性是有的,这个我早先做过真机。

这里选择用到上海和济源展开仿真(也就是说大都市都可以):

艾拉莫德片治类风湿怎么样
成都白癜风医院哪家好
腰椎病怎样治疗效果好
石家庄治白癜风的专业医院
每天早上起来手指关节僵硬疼
上海9月16日新增本土无症状感染者1同上

院171同上,痊愈住院191同上,在院治疗4同上,被害0同上;泌尿道HIV749同上。原有待排查的疑似患者0同上。 截至2022年9同年16日24时,总共境内外读写开放性住院患者5285...

友情链接