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

相亲网站上做绿叶的女人很多在线做logo的网站

相亲网站上做绿叶的女人很多,在线做logo的网站,wordpress图集,长沙公共资源交易中心官网官方文档#xff1a;通过用户首选项实现数据持久化 目录标题 使用场景第1步#xff1a;源码第2步#xff1a;启动模拟器第3步#xff1a;启动entry第6步#xff1a;操作样例2 使用场景 Preferences会将该数据缓存在内存中#xff0c;当用户读取的时候#xff0c;能够快…官方文档通过用户首选项实现数据持久化 目录标题 使用场景第1步源码第2步启动模拟器第3步启动entry第6步操作样例2 使用场景 Preferences会将该数据缓存在内存中当用户读取的时候能够快速从内存中获取数据当需要持久化时可以使用flush接口将内存中的数据写入持久化文件中。Preferences会随着存放的数据量越多而导致应用占用的内存越大因此Preferences不适合存放过多的数据也不支持通过配置加密适用的场景一般为应用保存用户的个性化设置字体大小是否开启夜间模式等。 第1步源码 import { common } from kit.AbilityKit; import dataPreferences from ohos.data.preferences;Entry Component struct Index {State changeFontSize: number 16;// 上下文private context: common.UIAbilityContext getContext(this) as common.UIAbilityContext//1. 获取preferenceprivate preferencesInstance: dataPreferences.Preferences dataPreferences.getPreferencesSync(this.context, { name: myStore });aboutToAppear(): void {//4. 页面打开后直接从preference中获取上一次的数据let result this.preferencesInstance.getSync(fontSizeKey, 16)this.changeFontSize Number(result)}build() {Column() {Row({ space: 10 }) {Text(当前进度一览).fontSize(this.changeFontSize)}.margin(20)Slider({value: this.changeFontSize,min: 14,max: 22,step: 2,style: SliderStyle.InSet}).showSteps(true).width(75%).onChange(async (value: number) {this.changeFontSize value//2. 保存数据this.preferencesInstance.putSync(fontSizeKey, this.changeFontSize);//3. 持久化数据this.preferencesInstance.flush()})}.backgroundColor(#f2f3f5).width(100%).height(100%)} } 第2步启动模拟器 第3步启动entry 第6步操作 样例2 import dataPreferences from ohos.data.preferences; import { common } from kit.AbilityKit;Entry Component struct Index_preferences2 {State message: string Hello World;private context:common.UIAbilityContext getContext(this) as common.UIAbilityContextprivate preferencesInstance: dataPreferences.Preferences dataPreferences.getPreferencesSync(this.context, { name: myStore });aboutToAppear(): void {let result this.preferencesInstance.getSync(messageKey,默认值1)this.message String(result)}build() {Row() {Column() {TextInput({text:this.message}).fontSize(20).fontWeight(FontWeight.Bold).onChange((value){this.message value})Button(保存).onClick((){this.preferencesInstance.putSync(message, this.message);this.preferencesInstance.flush()AlertDialog.show({message:保存成功})})Button(读取).onClick(() {let result this.preferencesInstance.getSync(messageKey,默认值2)this.message String(result)//获取到的数据不是String需要转换一下AlertDialog.show({message:this.message})console.log(test,result)})}.width(100%)}.height(100%)} }
http://www.hkea.cn/news/14436951/

相关文章:

  • 郑州网站推广¥做下拉去118cr大宗商品交易平台软件排行
  • 在线做网站图标wordpress删除示例页面
  • 合肥集团网站建设哪个好引擎网站推广法
  • 企业网站推广短平快做自媒体有哪些网站
  • 茶叶公司商城网站建设网站和微信订阅号优势
  • 开发公司年终工作总结ppt乐清seo公司推荐
  • 摄影网站方案wordpress widget
  • asp 网站地图生成贵阳app开发公司排名
  • 开发网站中心网站建设合同书相关附件
  • 网站开发 微信 支付微信推广软件
  • 怎么做网站倒计时seo技术最新黑帽
  • 安徽省住房和建设厅网站在线花钱做网站
  • vs2008可以做网站app界面设计分析六个方面
  • 安全中国asp.net网站开发项目实战培训班手机建站系统源码
  • 哪个网站可以做全网推广做简约头像网站
  • 大型网站怎么加载图片的网站用的字体
  • 做网站公司长沙上海住房城乡建设厅网站首页
  • wordpress添加dplayerseo优化博客
  • 怎样免费网站建设磁力珠
  • 特产网站怎么做凡科企业邮箱
  • 如何修改网站底部软件工程导论
  • 做网站需要准备哪些东西广东外贸网站推广
  • 网站的建设方面wordpress不同背景图片
  • 外贸高端网站建设山西山西省建设厅网站
  • 陶艺品网站模板百度问一问免费咨询
  • 网站上线怎么做天津响应式网站建设制作
  • 三门峡网站建设费用什么是网站静态页面
  • 信贷网站建设wordpress简体中文版下载地址
  • 做网站制作挣钱吗北京商场营业时间
  • 网站建设课程小结广东企业网站建设报价