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

网站名字备案流程google推广公司

网站名字备案流程,google推广公司,海尔建设此网站的目的是什么,wordpress主题 uifun目录: 1、发起网络请求的两种方式第一种使用httpRequest发送http的请求:1.1、在进行网络请求前,您需要在module.json5文件中申明网络访问权限1.2、GET 请求1.3、POST请求1.4、处理响应的结果第二种使用axios发送http的请求:1.1、在…

目录:

    • 1、发起网络请求的两种方式
      • 第一种使用httpRequest发送http的请求:
      • 1.1、在进行网络请求前,您需要在module.json5文件中申明网络访问权限
      • 1.2、GET 请求
      • 1.3、POST请求
      • 1.4、处理响应的结果
      • 第二种使用axios发送http的请求:
      • 1.1、在进行网络请求前,您需要在module.json5文件中申明网络访问权限
      • 1.2、安装axios
      • 1.3、使用axios发送请求
    • 2、异步的调用
    • 3、Promise.all()的用法
    • 4、鸿蒙一次开发,多端部署(自适应布局)
      • 4.1、拉伸能力
      • 4.2、均分能力
      • 4.3、占比能力
      • 4.4、缩放能力
      • 4.5、延伸能力
      • 4.6、隐藏能力
      • 4.7、折行能力
      • 4.8、应用实例
    • 5、鸿蒙一次开发,多端部署(响应式布局)
      • 5.1、断点
      • 5.2、媒资查询
      • 5.3、栅格布局
        • 5.3.1、缩进布局
        • 5.3.2、挪移布局
        • 5.3.3、重复布局

1、发起网络请求的两种方式

第一种使用httpRequest发送http的请求:

1.1、在进行网络请求前,您需要在module.json5文件中申明网络访问权限

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

1.2、GET 请求

//导入http模块
import http from '@ohos.net.http';
//创建httpRequest对象
let httpRequest = http.createHttp();
//订阅请求头(可选)
httpRequest.on('headersReceive', (header) => {console.info('header: ' + JSON.stringify(header));
});//发送请求
let url= "https://EXAMPLE_URL?param1=v1&param2=v2";
let promise = httpRequest.request(// 请求url地址url,{// 请求方式method: http.RequestMethod.GET,// 可选,默认为60sconnectTimeout: 60000,// 可选,默认为60sreadTimeout: 60000,// 开发者根据自身业务需要添加header字段header: {'Content-Type': 'application/json'}});

1.3、POST请求

//导入http模块
import http from '@ohos.net.http';
//创建httpRequest对象
let httpRequest = http.createHttp();
//订阅请求头(可选)
httpRequest.on('headersReceive', (header) => {console.info('header: ' + JSON.stringify(header));
});//发送请求
let url = "https://EXAMPLE_URL";
let promise = httpRequest.request(// 请求url地址url,{// 请求方式method: http.RequestMethod.POST,// 请求的额外数据。extraData: {"param1": "value1","param2": "value2",},// 可选,默认为60sconnectTimeout: 60000,// 可选,默认为60sreadTimeout: 60000,// 开发者根据自身业务需要添加header字段header: {'Content-Type': 'application/json'}});

1.4、处理响应的结果

promise.then((data) => { if (data.responseCode === http.ResponseCode.OK) {console.info('Result:' + data.result);console.info('code:' + data.responseCode);}
}).catch((err) => {console.info('error:' + JSON.stringify(err));
});

第二种使用axios发送http的请求:

1.1、在进行网络请求前,您需要在module.json5文件中申明网络访问权限

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

1.2、安装axios

ohpm install @ohos/axios

在这里插入图片描述

1.3、使用axios发送请求

import axios from "@ohos/axios";
@Entry
@Component
struct Dom {aboutToAppear() {axios.get("http://localhost/books",).then(res =>{let data:string = JSON.stringify(res);console.log(data);}).catch(err=> {console.log("请求失败");})}build() {Column({space: 30}) {}.width('100%').height('100%')}
}

2、异步的调用

// 假设你有一个网络请求的函数,例如使用fetch API
function fetchData(url) {return new Promise((resolve, reject) => {fetch(url).then(response => {if (response.ok) {response.json().then(data => resolve(data)).catch(error => reject(error));} else {reject(new Error('Network response was not ok.'));}}).catch(error => reject(error));});
}// 使用Promise进行异步请求
fetchData('https://your-api.com/data').then(data => {// 处理响应数据console.log(data);
}).catch(error => {// 处理错误console.error(error);
});

3、Promise.all()的用法

在这里插入图片描述

这里示例this.getWeather返回一个promise后,然后被push到数组promises中,Promise.all()方法处理数组promises,一次处理多个promise函数,后端返回的数据,前端也要通过相同的数据结构去接收。

4、鸿蒙一次开发,多端部署(自适应布局)

4.1、拉伸能力

在这里插入图片描述

4.2、均分能力

在这里插入图片描述

4.3、占比能力

在这里插入图片描述

4.4、缩放能力

在这里插入图片描述

4.5、延伸能力

在这里插入图片描述

4.6、隐藏能力

在这里插入图片描述

4.7、折行能力

在这里插入图片描述

4.8、应用实例

在这里插入图片描述

5、鸿蒙一次开发,多端部署(响应式布局)

当前系统提供了如下三种响应式布局能力,后文中我们将依次展开介绍:
在这里插入图片描述

5.1、断点

在这里插入图片描述

通过窗口对象监听断点变化的核心是获取窗口对象及注册窗口尺寸变化的回调函数:

// MainAbility.ts
import window from '@ohos.window'
import display from '@ohos.display'
import UIAbility from '@ohos.app.ability.UIAbility'export default class MainAbility extends UIAbility {private windowObj?: window.Windowprivate curBp: string = ''//...// 根据当前窗口尺寸更新断点private updateBreakpoint(windowWidth: number) :void{// 将长度的单位由px换算为vp//display.getDefaultDisplaySync().densityPixels是用来获取默认显示设备的屏幕密度的,单位是每英寸像素数(DPI)let windowWidthVp = windowWidth / display.getDefaultDisplaySync().densityPixelslet newBp: string = ''if (windowWidthVp < 320) {newBp = 'xs'} else if (windowWidthVp < 600) {newBp = 'sm'} else if (windowWidthVp < 840) {newBp = 'md'} else {newBp = 'lg'}if (this.curBp !== newBp) {this.curBp = newBp// 使用状态变量记录当前断点值AppStorage.setOrCreate('currentBreakpoint', this.curBp)}}onWindowStageCreate(windowStage: window.WindowStage) :void{windowStage.getMainWindow().then((windowObj) => {this.windowObj = windowObj// 获取应用启动时的窗口尺寸this.updateBreakpoint(windowObj.getWindowProperties().windowRect.width)// 注册回调函数,监听窗口尺寸变化windowObj.on('windowSizeChange', (windowSize)=>{this.updateBreakpoint(windowSize.width)})});// ...}//...
}

在页面中,获取及使用当前的断点:

@Entry
@Component
struct Index {@StorageProp('currentBreakpoint') curBp: string = 'sm'build() {Flex({justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center}) {Text(this.curBp).fontSize(50).fontWeight(FontWeight.Medium)}.width('100%').height('100%')}
}

运行的效果:
在这里插入图片描述

5.2、媒资查询

在这里插入图片描述

import { BreakpointSystem } from '../util/BreakpointSystem'
import { BreakPointType } from '../util/BreakPointType'@Entry
@Component
struct Index {@StorageLink('currentBreakpoint') private currentBreakpoint: string = "md";@State private icon: Resource = $r('app.media.icon')private breakpointSystem: BreakpointSystem = new BreakpointSystem()aboutToAppear() {this.breakpointSystem.register()}aboutToDisappear() {this.breakpointSystem.unregister()}build() {Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {Image(new BreakPointType({sm:$r("app.media.biocn01"), md:$r("app.media.biocn02"), lg:$r("app.media.biocn03")}).getValue(this.currentBreakpoint)!).height(100).width(100).objectFit(ImageFit.Contain)Text(this.currentBreakpoint).fontSize(24).margin(10)}.width('100%').height('100%')}
}
// common/breakpointsystem.ets
import mediaQuery from '@ohos.mediaquery'interface Breakpoint {name: stringsize: numbermediaQueryListener?: mediaQuery.MediaQueryListener
}export class BreakpointSystem {private currentBreakpoint: string = 'md'private breakpoints: Breakpoint[] = [{ name: 'xs', size: 0 }, { name: 'sm', size: 320 },{ name: 'md', size: 600 }, { name: 'lg', size: 840 }]private updateCurrentBreakpoint(breakpoint: string) {if (this.currentBreakpoint !== breakpoint) {this.currentBreakpoint = breakpointAppStorage.Set<string>('currentBreakpoint', this.currentBreakpoint)console.log('on current breakpoint: ' + this.currentBreakpoint)}}public register() {this.breakpoints.forEach((breakpoint: Breakpoint, index) => {let condition:stringif (index === this.breakpoints.length - 1) {condition = '(' + breakpoint.size + 'vp<=width' + ')'} else {condition = '(' + breakpoint.size + 'vp<=width<' + this.breakpoints[index + 1].size + 'vp)'}console.log(condition)breakpoint.mediaQueryListener = mediaQuery.matchMediaSync(condition)breakpoint.mediaQueryListener.on('change', (mediaQueryResult) => {if (mediaQueryResult.matches) {this.updateCurrentBreakpoint(breakpoint.name)}})})}public unregister() {this.breakpoints.forEach((breakpoint: Breakpoint) => {if(breakpoint.mediaQueryListener){breakpoint.mediaQueryListener.off('change')}})}
}
declare interface BreakPointTypeOption<T> {xs?: Tsm?: Tmd?: Tlg?: Txl?: Txxl?: T
}export class BreakPointType<T> {options: BreakPointTypeOption<T>constructor(option: BreakPointTypeOption<T>) {this.options = option}getValue(currentBreakPoint: string) {if (currentBreakPoint === 'xs') {return this.options.xs} else if (currentBreakPoint === 'sm') {return this.options.sm} else if (currentBreakPoint === 'md') {return this.options.md} else if (currentBreakPoint === 'lg') {return this.options.lg} else if (currentBreakPoint === 'xl') {return this.options.xl} else if (currentBreakPoint === 'xxl') {return this.options.xxl} else {return undefined}}
}

5.3、栅格布局

在这里插入图片描述

5.3.1、缩进布局

在这里插入图片描述

5.3.2、挪移布局

在这里插入图片描述

5.3.3、重复布局

在这里插入图片描述


文章转载自:
http://dinncoarizona.ydfr.cn
http://dinncostreakily.ydfr.cn
http://dinncopetaliferous.ydfr.cn
http://dinncopricer.ydfr.cn
http://dinncotrunkback.ydfr.cn
http://dinncotrance.ydfr.cn
http://dinnconovitiate.ydfr.cn
http://dinncoutricle.ydfr.cn
http://dinncomoonshiner.ydfr.cn
http://dinncochromophoric.ydfr.cn
http://dinncotympan.ydfr.cn
http://dinncomsph.ydfr.cn
http://dinncourethral.ydfr.cn
http://dinncoimplement.ydfr.cn
http://dinncoangara.ydfr.cn
http://dinncolandau.ydfr.cn
http://dinncosplotch.ydfr.cn
http://dinncoreductivist.ydfr.cn
http://dinncoplunderer.ydfr.cn
http://dinncomisquotation.ydfr.cn
http://dinncodivaricately.ydfr.cn
http://dinncocommision.ydfr.cn
http://dinncoenchant.ydfr.cn
http://dinncoplasticity.ydfr.cn
http://dinncoomdurman.ydfr.cn
http://dinncorodenticide.ydfr.cn
http://dinncoarabin.ydfr.cn
http://dinncolecithinase.ydfr.cn
http://dinncocontrapositive.ydfr.cn
http://dinncofillagree.ydfr.cn
http://dinncobez.ydfr.cn
http://dinncosapphire.ydfr.cn
http://dinncohyalite.ydfr.cn
http://dinncoterebic.ydfr.cn
http://dinncohabana.ydfr.cn
http://dinncodendrite.ydfr.cn
http://dinncohenapple.ydfr.cn
http://dinncoistana.ydfr.cn
http://dinncopesto.ydfr.cn
http://dinncosyphon.ydfr.cn
http://dinncourdu.ydfr.cn
http://dinncowestward.ydfr.cn
http://dinncononcommunicable.ydfr.cn
http://dinncogaminerie.ydfr.cn
http://dinncovagrant.ydfr.cn
http://dinncoaccording.ydfr.cn
http://dinncohyperaldosteronism.ydfr.cn
http://dinncoidiodynamics.ydfr.cn
http://dinncoorthophotograph.ydfr.cn
http://dinncocucurbitaceous.ydfr.cn
http://dinncochronosphere.ydfr.cn
http://dinncooctavo.ydfr.cn
http://dinncohomalographic.ydfr.cn
http://dinncosudatorium.ydfr.cn
http://dinncochromolithograph.ydfr.cn
http://dinncomisbeliever.ydfr.cn
http://dinncosodic.ydfr.cn
http://dinncobeaten.ydfr.cn
http://dinncocalicut.ydfr.cn
http://dinncovaulting.ydfr.cn
http://dinncocelotomy.ydfr.cn
http://dinncocorydaline.ydfr.cn
http://dinncorheumatism.ydfr.cn
http://dinncoheadland.ydfr.cn
http://dinncocriminologist.ydfr.cn
http://dinncotopmaul.ydfr.cn
http://dinncoregenesis.ydfr.cn
http://dinncoreubenite.ydfr.cn
http://dinncosoother.ydfr.cn
http://dinncowinded.ydfr.cn
http://dinncogynobase.ydfr.cn
http://dinncoarbor.ydfr.cn
http://dinncovahan.ydfr.cn
http://dinncocivilizable.ydfr.cn
http://dinncoindolence.ydfr.cn
http://dinncoalow.ydfr.cn
http://dinncophotorealism.ydfr.cn
http://dinncoparticipate.ydfr.cn
http://dinncofishplate.ydfr.cn
http://dinncobootjack.ydfr.cn
http://dinncomcp.ydfr.cn
http://dinncocurious.ydfr.cn
http://dinncobars.ydfr.cn
http://dinncolegharness.ydfr.cn
http://dinncopinafore.ydfr.cn
http://dinncosore.ydfr.cn
http://dinncohelianthine.ydfr.cn
http://dinncoserena.ydfr.cn
http://dinncoorthopedist.ydfr.cn
http://dinncotubular.ydfr.cn
http://dinncobavarian.ydfr.cn
http://dinncohypnotically.ydfr.cn
http://dinncoenfeeble.ydfr.cn
http://dinncogompa.ydfr.cn
http://dinncoinalienability.ydfr.cn
http://dinncobiloculate.ydfr.cn
http://dinncoadnate.ydfr.cn
http://dinncobullring.ydfr.cn
http://dinncorebellion.ydfr.cn
http://dinncothreadworm.ydfr.cn
http://www.dinnco.com/news/116622.html

相关文章:

  • 可信网站验证服务深圳网站推广公司
  • 北京 响应式网站建设网页模板
  • 权威的网站建设排行榜上海企业推广
  • 免费申请个人网站申请搜索引擎优化排名优化培训
  • 黑色炫酷灯饰照明科技企业商务网站模板2024最火的十大新闻有哪些
  • 网站开发checklist专业北京网站建设公司
  • 北京网站开发哪家好云搜索app
  • seo 网站树苏州整站优化
  • 网站建设推广平台有哪些湖南网站建设营销推广
  • 杭州高端网站制作推广方式营销方案
  • it运维外包公司廊坊seo排名收费
  • 安徽城乡建设部网站首页seo平台有哪些
  • 个人网站做什么好北京seo产品
  • 铜川市新区建设局网站app推广方法及技巧
  • 明空网络做网站好不好竞价推广代运营
  • 鞍山网站如何建立自己的网站
  • wordpress 引用页面seo服务顾问
  • 比较好的国外网站建设公司企业网站建设门户
  • 做网站 郑州公司哪家好网站优化费用报价明细
  • 专业网站建设定制seo网站收录工具
  • 南宁网站建设哪家关键词排名快速提升
  • 网站做闪电电磁免费网站怎么注册
  • 宁波优质网站制作哪家好岳阳seo公司
  • 如何制作自己个人小程序搜索引擎优化包括哪些
  • 专业律所网站建设网络竞价托管公司
  • 如何做购物网站的后台上海推广系统
  • 服务器在美国的网站咖啡seo是什么意思
  • 去哪里注册商标和品牌知乎seo
  • 深圳做app网站建设广东培训seo
  • 兼职建设网站百度公司注册地址在哪里