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

校友网站建设的重要性销售类wordpress

校友网站建设的重要性,销售类wordpress,3d动画制作自学教程,2144网页游戏大厅鸿蒙Harmony-UIAbility内状态-LocalStorage详细介绍 1.1 Localstorage的概念 LocalStorage是页面级的UI状态存储,通过Entry装饰器接收的参数可以在页面内共享同一个LocalStorage实例,LocalStorage也可以在UIAbility内,页面间共享状态 1.2 Lo…

鸿蒙Harmony-UIAbility内状态-LocalStorage详细介绍

1.1 Localstorage的概念

LocalStorage是页面级的UI状态存储,通过@Entry装饰器接收的参数可以在页面内共享同一个LocalStorage实例,LocalStorage也可以在UIAbility内,页面间共享状态

1.2 LocalStorage单个页面的使用方法

1.2.1 单个页面的数据状态存储方法

  1. 准备一个共享数据,键值对的方式存储

  2. 创建LocalStorage实例:const storage = new LocalStorage({key:value})

  3. 单向 @LocalStorageProp(‘user’)组件内可变

  4. 双向 #LocalStorageLink(‘user’)全局均可变

1.2.2 案例演示

  1. 准备共享数据
const data:Record<string,string> = {'uname':'公孙离','age':'18'
}
  1. 创建一个storage实例
const storage = new LocalStorage(data)
  1. 使用共享数据库
1.@Entry(storage)
//表示我要从共享数据库中取出uname字段   具体需要取出什么字段根据自己需求即可@LocalStorageLink('uname')//给取出的字段取一个别名,需要赋初始值。因为可能拿不到message: string = ''
  1. 具体代码实现
const data:Record<string,string> = {'uname':'公孙离','age':'18'
}
const storage = new LocalStorage(data)
@Entry(storage)
@Component
struct TestLocalStorage03 {@LocalStorageLink('uname')message:string = ''build() {Column() {Text(this.message)Button('改变父组件的信息').onClick(()=>{this.message = '孙尚香'})child001()}.height('100%').width('100%')}
}@Component
struct child001 {@LocalStorageLink('uname')message:string = ''build() {Column(){Text('-------------------------------------------')Text(this.message)Button('改变子组件的状态').onClick(()=>{this.message = '西施'})}}
}

1.2.3 效果展示

img

1.3 LocalStorage多个页面共享UIAbility的使用方法

1.3.1 多个页面的使用方法

  1. 依旧是准备共享数据,放置在设置当前应用的加载页面(UIAbility共享),只要是当前windowstage内的界面,都可以共享这份数据
  2. 在设置应用的加载页面创建storage实例
  3. 通过LocalStorage里面的方法getShared获取数据

1.3.2 案例演示

  1. 准备数据
  const data:Record<string,string> = {'uname':'公孙离','age':'18',}const storage = new LocalStorage(data)
  1. 创建storage实例,将storage传递给页面
    1.const storage = new LocalStorage(data)2.  windowStage.loadContent('pages/10/TestLocalStorage03',storage);
  1. 接收数据
const storage = LocalStorage.getShared()
//其他步骤同单个页面传输吗,这里就不再叙述
  1. 完整代码展示
  • UIAbility内代码
  onWindowStageCreate(windowStage: window.WindowStage): void {const data:Record<string,string> = {'uname':'公孙离','age':'18',}const storage = new LocalStorage(data)// //只要是当前windowStage内的界面,都可以共享这份数据windowStage.loadContent('pages/10/TestLocalStorage03',storage);}
  • 页面1
// const data:Record<string,string> = {
import { router } from '@kit.ArkUI'//   'uname':'公孙离',
//   'age':'18'
// }
const storage = LocalStorage.getShared()@Entry(storage)
@Component
struct TestLocalStorage03 {@LocalStorageLink('uname')message: string = ''build() {Column() {Text(this.message)Button('改变父组件的信息').onClick(() => {this.message = '孙尚香'})child001()}.height('100%').width('100%')}
}@Component
struct child001 {@LocalStorageLink('uname')message: string = ''build() {Column() {Text('-------------------------------------------')Text(this.message)Button('改变子组件的状态').onClick(() => {this.message = '西施'})Button('切换页面').onClick(() => {router.pushUrl({url: 'pages/10/TextLocalStorage2'})})}}
}
  • 页面2
import { router } from '@kit.ArkUI'const storage = LocalStorage.getShared()
@Entry(storage)
@Component
struct TextLocalStorage2 {@LocalStorageLink('uname')message: string = ''build() {Column() {Text(this.message)Button('改变信息').onClick(()=>{this.message = '刘备'})Button('back').onClick(()=>{router.back()})}.height('100%').width('100%')}
}

1.3.3 效果展示

img


文章转载自:

http://x1YipcEd.hcxhz.cn
http://NnfGDDwI.hcxhz.cn
http://MIH1UIcB.hcxhz.cn
http://nUlVxKKt.hcxhz.cn
http://dUDqve9E.hcxhz.cn
http://g5aTAyPB.hcxhz.cn
http://G5ReuQUI.hcxhz.cn
http://6woejfXo.hcxhz.cn
http://2OBytzOQ.hcxhz.cn
http://XrHkmGWk.hcxhz.cn
http://0RawAMVG.hcxhz.cn
http://AwA9xHQv.hcxhz.cn
http://0imWgP5L.hcxhz.cn
http://lRsu7bmt.hcxhz.cn
http://qPb8Snlv.hcxhz.cn
http://WoeIx7qZ.hcxhz.cn
http://VAi8nGU7.hcxhz.cn
http://GGMRthPs.hcxhz.cn
http://ieaEdjKQ.hcxhz.cn
http://OXvOJ8Yy.hcxhz.cn
http://hYjTajeg.hcxhz.cn
http://a7K46LWk.hcxhz.cn
http://0dRp8Roo.hcxhz.cn
http://LYLHuvBV.hcxhz.cn
http://uiVlH8CI.hcxhz.cn
http://28cwXEoE.hcxhz.cn
http://35bc0HNM.hcxhz.cn
http://ZU6RYj9p.hcxhz.cn
http://I9x8sHDv.hcxhz.cn
http://evjs3GnT.hcxhz.cn
http://www.dtcms.com/wzjs/728013.html

相关文章:

  • 怎么做flash网站运动网站源码
  • wordpress手机显示图片江苏网站建设seo优化
  • wordpress 三站合一快速搭建网站的好处
  • 做金融网站需要什么营业执照家用电脑可以做网站服务器
  • 专业网站建设网站建设销售技巧
  • 炫酷的html5网站京东网站怎么做
  • 外贸公司 网站程序员网站
  • 网站中的游戏是怎么做的wordpress免费网站模板
  • 手机移动端网站做多大企业网站建设公司郑州
  • 个人网站做得优秀的深圳十大穷人区
  • 奢侈品+网站建设方案微信微商城怎么做
  • 建设教育工程网站重庆网站建设是什么
  • 1千万人网站维护成本群晖手动安装wordpress
  • 二手商品交易网站开发做加工都在哪个网站推广
  • 关于校园网站建设的建议装潢设计费用怎么算
  • 淘宝客网站还可以做吗手机如何建立网站步骤
  • 泸州市往建局建设银行网站名称中信建设有限责任公司龙芳
  • 设计制作网站的公司seo搜索优化工程师招聘
  • 临沂建手机网站公司人力外包项目发布平台
  • 信息时代网站建设的重要性辽宁建设工程信息网查
  • 上海网站推广公司排名郑州建设工程信息网站
  • 做网站 怎么赚钱吗北京燕华工程建设有限公司网站
  • 韩国企业网站模板下载怎么做英文版的网站
  • 湖北省职业能力建设处网站东莞网站建设案例
  • 中山网站建设金科重庆seo排名电话
  • 中午网站做google广告好吗自己做qq头像的网站
  • 景区智慧旅游网站建设wordpress手机版错误
  • 欧美企业网站模板开一个做网站的公司
  • 网站建设 部署与发布题库浙江建设职业技术学院继续教育学院网站
  • 策划与设计一个电子商务网站网站服务器干啥