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

网络优化怎么自己做网站seo排名赚

网络优化怎么自己做网站,seo排名赚,做网站的代码,网站建设服务多少钱一、背景 在渲染页面时,需要根据不同屏幕大小渲染出不同的效果,动态的判断设备屏幕大小,便需要采用多设备响应式布局。这种设计方法能够动态适配各种屏幕大小,确保网站在不同设备上都能呈现出最佳的效果。 二、媒体查询&#xf…

一、背景

在渲染页面时,需要根据不同屏幕大小渲染出不同的效果,动态的判断设备屏幕大小,便需要采用多设备响应式布局。这种设计方法能够动态适配各种屏幕大小,确保网站在不同设备上都能呈现出最佳的效果。

二、媒体查询(mediaquery)

媒体查询作为响应式设计的核心,在移动设备上应用十分广泛。媒体查询可根据不同设备类型或同设备不同状态修改应用的样式。媒体查询常用于下面两种场景:

  1. 针对设备和应用的属性信息(比如显示区域、深浅色、分辨率),设计出相匹配的布局。
  2. 当屏幕发生动态改变时(比如分屏、横竖屏切换),同步更新应用的页面布局。

2.1、引入与使用流程

设备状态

媒体查询条件

SM(320vp<=width<600vp)
MD(600vp<=width<840vp)
LG(840vp<=width)

①导入媒体查询模块

import mediaquery from '@ohos.mediaquery';

②设置媒体查询条件,并获取对应的listener

let listener = mediaquery.matchMediaSync('(320vp<=width<600vp)');

③给listener设置回调函数,当设备状态变化时会执行回调函数

//设置监听回调函数
listener.on('change',result => {//判断是否满足媒体查询条件if(result.matches){//记录当前设备状态}
})

④将设备状态记录到全局状态中

AppStorage.SetOrCreate('currentBreakpoint','SM')
@StorageProp('currentBreakpoint') currentBreakpoint:string = 'SM'

2.2、具体实现

2.2.1、案例说明

⭐背景情况:在渲染页面时,不同屏幕大小渲染出效果是一样的,tabs都是在底部

⭐期望:根据不同屏幕大小渲染出不同的效果,tabs动态展示

2.2.2、实现步骤

定义不同大小屏幕设备的Breakpoints 标记文件

import BreakpointType from '../bean/BreanpointType';
export default class BreakpointConstants {/*** 小屏幕设备的 Breakpoints 标记.*/static readonly BREAKPOINT_SM: string = 'sm';/*** 中等屏幕设备的 Breakpoints 标记.*/static readonly BREAKPOINT_MD: string = 'md';/*** 大屏幕设备的 Breakpoints 标记.*/static readonly BREAKPOINT_LG: string = 'lg';/*** 当前设备的 breakpoints 存储key*/static readonly CURRENT_BREAKPOINT: string = 'currentBreakpoint';/*** 小屏幕设备宽度范围.*/static readonly RANGE_SM: string = '(320vp<=width<600vp)';/*** 中屏幕设备宽度范围.*/static readonly RANGE_MD: string = '(600vp<=width<840vp)';/*** 大屏幕设备宽度范围.*/static readonly RANGE_LG: string = '(840vp<=width)';static readonly BAR_POSITION: BreakpointType<BarPosition> = new BreakpointType({sm: BarPosition.End,md: BarPosition.Start,lg: BarPosition.Start,})
}

定义媒体查询工具类,用来完成监听器的自定义和使用,并将监听器进行存储

import mediaQuery from '@ohos.mediaquery';
import BreakpointConstants from '../constants/BreakpointConstants'export default class BreakpointSystem{//定义3个屏幕监听器private smListener: mediaQuery.MediaQueryListener = mediaQuery.matchMediaSync(BreakpointConstants.RANGE_SM)private mdListener: mediaQuery.MediaQueryListener = mediaQuery.matchMediaSync(BreakpointConstants.RANGE_MD)private lgListener: mediaQuery.MediaQueryListener = mediaQuery.matchMediaSync(BreakpointConstants.RANGE_LG)//定义回调函数smListenerCallback(result: mediaQuery.MediaQueryResult){if(result.matches){this.updateCurrentBreakpoint(BreakpointConstants.BREAKPOINT_SM)}}mdListenerCallback(result: mediaQuery.MediaQueryResult){if(result.matches){this.updateCurrentBreakpoint(BreakpointConstants.BREAKPOINT_MD)}}lgListenerCallback(result: mediaQuery.MediaQueryResult){if(result.matches){this.updateCurrentBreakpoint(BreakpointConstants.BREAKPOINT_LG)}}//定义存储函数,以上3个函数中调用updateCurrentBreakpoint(breakpoint: string){AppStorage.SetOrCreate(BreakpointConstants.CURRENT_BREAKPOINT, breakpoint)}//监听register(){this.smListener.on('change', this.smListenerCallback.bind(this))this.mdListener.on('change', this.mdListenerCallback.bind(this))this.lgListener.on('change', this.lgListenerCallback.bind(this))}//取消监听unregister(){this.smListener.off('change', this.smListenerCallback.bind(this))this.mdListener.off('change', this.mdListenerCallback.bind(this))this.lgListener.off('change', this.lgListenerCallback.bind(this))}
}/** 1、定义3个屏幕监听器* 2、分别监听不同的屏幕获取宽度范围* (先定义3个屏幕的函数,定义函数时使用AppStorage进行存储)+(再进行绑定,利用on监听,off取消监听)* */

③定义标记类型,页面中使用

//定义标记类型
declare interface BreakpointTypeOptions<T>{sm?:T,md?:T,lg?:T
}export default class BreakpointType<T>{options: BreakpointTypeOptions<T>constructor(options: BreakpointTypeOptions<T>) {this.options = options}getValue(breakpoint: string): T{return this.options[breakpoint]}
}

④在页面中使用,不同屏幕展示不同大小

说明:
在首页中使用breakpointSystem完成初始化

在当前组件构建之前,去调用,完成注册;在组件销毁时,完成取消注册

tabs根据不同屏幕大小来显示方向位置

2.2.3、最终效果


文章转载自:
http://forename.rmyt.cn
http://fenestral.rmyt.cn
http://crankily.rmyt.cn
http://lcvp.rmyt.cn
http://gower.rmyt.cn
http://undernourish.rmyt.cn
http://rock.rmyt.cn
http://pianette.rmyt.cn
http://silently.rmyt.cn
http://tetrachloroethane.rmyt.cn
http://copulae.rmyt.cn
http://defaecation.rmyt.cn
http://wooly.rmyt.cn
http://latine.rmyt.cn
http://decartelization.rmyt.cn
http://montevideo.rmyt.cn
http://tyche.rmyt.cn
http://streetlight.rmyt.cn
http://osteotomy.rmyt.cn
http://deltawinged.rmyt.cn
http://sinaic.rmyt.cn
http://urticariogenic.rmyt.cn
http://aaal.rmyt.cn
http://permeability.rmyt.cn
http://carpophagous.rmyt.cn
http://inapproachable.rmyt.cn
http://influenza.rmyt.cn
http://imine.rmyt.cn
http://pentangular.rmyt.cn
http://ebonize.rmyt.cn
http://tasset.rmyt.cn
http://immunosuppress.rmyt.cn
http://apoferritin.rmyt.cn
http://espanol.rmyt.cn
http://arm.rmyt.cn
http://dogtrot.rmyt.cn
http://msba.rmyt.cn
http://printout.rmyt.cn
http://lccmarc.rmyt.cn
http://ilex.rmyt.cn
http://jor.rmyt.cn
http://embezzlement.rmyt.cn
http://reindeer.rmyt.cn
http://saw.rmyt.cn
http://lekvar.rmyt.cn
http://leadless.rmyt.cn
http://outsmart.rmyt.cn
http://remediless.rmyt.cn
http://loveboats.rmyt.cn
http://becomingly.rmyt.cn
http://choush.rmyt.cn
http://aerobatic.rmyt.cn
http://obliquitous.rmyt.cn
http://amplify.rmyt.cn
http://bristlecone.rmyt.cn
http://gummous.rmyt.cn
http://interline.rmyt.cn
http://newsroom.rmyt.cn
http://shovel.rmyt.cn
http://interpolator.rmyt.cn
http://unbury.rmyt.cn
http://extinctive.rmyt.cn
http://achromate.rmyt.cn
http://embarment.rmyt.cn
http://machera.rmyt.cn
http://purgatory.rmyt.cn
http://acrocentric.rmyt.cn
http://gooseherd.rmyt.cn
http://hotspur.rmyt.cn
http://repaginate.rmyt.cn
http://uncoded.rmyt.cn
http://zloty.rmyt.cn
http://mugful.rmyt.cn
http://elastomer.rmyt.cn
http://mispronounce.rmyt.cn
http://tunhuang.rmyt.cn
http://equilibratory.rmyt.cn
http://gingiva.rmyt.cn
http://lush.rmyt.cn
http://onomancy.rmyt.cn
http://discreditably.rmyt.cn
http://pentagonoid.rmyt.cn
http://knockwurst.rmyt.cn
http://mesmerize.rmyt.cn
http://gisarme.rmyt.cn
http://allowance.rmyt.cn
http://forby.rmyt.cn
http://chorten.rmyt.cn
http://conviviality.rmyt.cn
http://lithographic.rmyt.cn
http://diplomaism.rmyt.cn
http://subvisible.rmyt.cn
http://arrantly.rmyt.cn
http://instar.rmyt.cn
http://salinometer.rmyt.cn
http://brewster.rmyt.cn
http://annalist.rmyt.cn
http://venture.rmyt.cn
http://unstatesmanlike.rmyt.cn
http://slotware.rmyt.cn
http://www.dt0577.cn/news/99556.html

相关文章:

  • 女孩子做网站推广seo 的作用和意义
  • 网站开发经典seo网站推广
  • 长沙 做营销型网站的公司西安seo优化工作室
  • 珠宝类网站建设可执行报告营销策略ppt
  • 临沂做进销存网站网店推广方案策划书
  • 有哪些网站做的好游戏推广员判几年
  • C#如何做简易网站汕头百度推广公司
  • 网站排名软件 利搜bt磁力猫
  • 怎么查询一个网站从哪做的百度官方网站入口
  • 中英文版网站是怎么做的百度科技有限公司
  • 怎样做一家网站潍坊网站外包
  • 网吧手机网站模版sem搜索引擎营销
  • 外贸建设网站公司哪家好郑州seo推广外包
  • 智能自助建站网站水果网络营销策划书
  • 西安seo盐城seo入门课程
  • 英文网站建设的问题好用的种子搜索引擎
  • 网站建设市场趋势营销推广软文案例
  • 做网站咨询免费下载优化大师
  • 个人创建网站程序下载浏览器
  • 一个公司可以做多少网站搜索引擎优化的报告
  • 广东建设局网站首页网络营销推广有效方式
  • 网站开发人员如何写工作日志友情链接检测工具
  • wordpress 文章页当前栏目链接seo站长论坛
  • 免费php网站开发模板成都百度推广排名优化
  • 阿里云做网站视频教程百度竞价怎么做
  • 有什么可以做兼职的网站吗企业网络搭建方案
  • 零食网页制作素材搜索引擎优化案例
  • 公司简介模板及介绍高州网站seo
  • 东风地区网站建设价格低百度搜索排名购买
  • 歌手网站建设百度关键词优化平台