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

望京做网站的公司爱站网关键词怎么挖掘

望京做网站的公司,爱站网关键词怎么挖掘,wordpress统计展示插件,网站开发技术有什么软件开发需求:有一个字符串数组,可以通过弹框编辑其中的某个字符串,编辑完成后更新数组并持久化这个数组。 这个需求算是很简单,很常见的需求了。但是,开发过程中却遇到了一个不小的难题。 我的数组内容需要在组件中显示…

开发需求:有一个字符串数组,可以通过弹框编辑其中的某个字符串,编辑完成后更新数组并持久化这个数组。

这个需求算是很简单,很常见的需求了。但是,开发过程中却遇到了一个不小的难题。

我的数组内容需要在组件中显示,数据更新,页面刷新。所以,用@state装饰器修饰数组。

然后,点击某个字符串内容弹出customDialog,用户修改,确认后将修改的字符串回传,同时,修改数组的内容,持久化数组。一番操作猛如虎,结果一看直接崩溃

而且这个崩溃从以上日志是真看不出来为啥。不断的删减代码发现一个官方问题。@state修饰的属性,在customDialog回调中利用用户首选项持久化会崩溃,至于为啥,估计也就官方知道。

结果有了,贴一下我的崩溃示例代码

import Prompt from '@system.prompt'
import dataPreferences from '@ohos.data.preferences'@Entry
@Component
struct Index {@State currentTitle: string = '点击我'//需要持久化的数据@State dataArray: string[] = ['654','357','65456','35723']private templateDataManager = new BarrageTemplateModel()//自定义弹框editDialogController: CustomDialogController = new CustomDialogController({builder: CustomEditDialog({confirm: this.onConfirm.bind(this),currentTitle:$currentTitle}),autoCancel: false,alignment: DialogAlignment.Center,offset: { dx: 0, dy: -20 },gridCount: 4,customStyle: false})//弹框修改完成回调onConfirm() {this.dataArray.splice(0,1)     
//这里会导致崩溃   
this.templateDataManager.saveTemplateData(getContext(this),'kUserTemplateKey_HanHua',copy)}build() {Row() {Column() {Text(this.currentTitle).fontSize(50).fontWeight(FontWeight.Bold).onClick(() => {//这样直接操作,不牵扯dialog就不崩溃// this.dataArray.splice(0,1)// this.templateDataManager.saveTemplateData(getContext(this),'kUserTemplateKey_HanHua',this.dataArray)// Prompt.showToast({message:'点击了'})//这样会崩溃if (this.editDialogController != undefined) {this.editDialogController.open()}})}.width('100%')}.height('100%')}
}//弹出框
@CustomDialog
struct CustomEditDialog {@Link currentTitle: stringprivate tempTitle: string = ''controller: CustomDialogControllercancel: () => voidconfirm: () => voidbuild() {Column() {TextArea({text: this.currentTitle}).backgroundColor(0xffffff).fontColor(Color.Black).fontSize(20).width('100%').height(200).margin(20).onChange((value: string) => { //显示键盘if (value) {this.tempTitle = value;}})Divider().opacity(0.5).width('100%').color('#D3D3D3')Row() {Text('取消').backgroundColor(0xffffff).fontColor(Color.Black).fontSize(20).margin(10).height('100%').width('45%').textAlign(TextAlign.Center).onClick(() => {this.controller.close()this.cancel()})Divider().vertical(true).color('#D3D3D3')Text('确定').backgroundColor(0xffffff).fontColor(Color.Black).fontSize(20).margin(10).width('45%').height('100%').textAlign(TextAlign.Center).onClick(() => {this.currentTitle = this.tempTitlethis.controller.close()this.confirm()})}.justifyContent(FlexAlign.SpaceEvenly).width('100%').height(60)}}
}//存储数据的类
class BarrageTemplateModel {saveTemplateData(context: Context,key: string, hanHuaArray: string[]) {console.log('存储用户持久化存储的模版:000='+hanHuaArray.toString())dataPreferences.getPreferences(context,"PREFERENCE_KEY",(err,preference) =>{if (err) {console.log('存储用户持久化存储的模版:err1='+err)return}console.log('存储用户持久化存储的模版:success1=')preference.put(key,hanHuaArray,(err) =>{if (err) {console.log('存储用户持久化存储的模版:err2='+err)return}console.log('存储用户持久化存储的模版:success2=')preference.flush((err) => {console.log('存储用户持久化存储的模版:success3=')if (err) {console.log('存储用户持久化存储的模版:err3='+err)return}console.log('存储用户持久化存储的模版:success4=')console.log('存储用户持久化存储的模版:'+hanHuaArray.toString())})})})}
}

查了不少资料,一开始认为是不是因为用户首选项不支持字符串数组,后来看文档是支持的。

然后,认为是不是因为回调的bind(this),但是不添加bind(this)又会导致回调中的this不是当前组件,访问不到属性。

直到后来注意到我的数组用了@state修饰,去掉后果然不崩溃了。但是我的组件中又需要这个数组用@state修饰。进退两难。。。。

最后只能来个曲线救国,我持久化的数据不直接操作@state的对象,而是持久化copy出来新的一份,就不崩溃了,如下

//弹出框的回调方法onConfirm() {//假设这是对数组进行操作了this.dataArray.splice(0,1)//回调中我将dataArray复制存储在copy中const copy = this.dataArray.map( num => num )//持久化copy数据,不操作dataArray
this.templateDataManager.saveTemplateData(getContext(this),'kUserTemplateKey_HanHua',copy)}

这个操作(复制一份,持久化复制的内容)真的辣眼睛,但是这样确实不崩溃了,值得一提的是:如果你直接const copy = this.dataArray也是不行的,除非复制出来新的一块内存。这个问题估计官方会修复,而且这个操作也太常见了。。。。


文章转载自:
http://exhort.c7624.cn
http://all.c7624.cn
http://conformity.c7624.cn
http://antipsychiatry.c7624.cn
http://serviceable.c7624.cn
http://iu.c7624.cn
http://hydrocarbon.c7624.cn
http://brahmanist.c7624.cn
http://torun.c7624.cn
http://gypsiferous.c7624.cn
http://manoeuver.c7624.cn
http://ecumenic.c7624.cn
http://frame.c7624.cn
http://synovitis.c7624.cn
http://uncompassionate.c7624.cn
http://varioloid.c7624.cn
http://airstop.c7624.cn
http://ephebeion.c7624.cn
http://recipher.c7624.cn
http://fifer.c7624.cn
http://cuckold.c7624.cn
http://meadowlark.c7624.cn
http://cashier.c7624.cn
http://doddered.c7624.cn
http://wonderland.c7624.cn
http://sortable.c7624.cn
http://bulimia.c7624.cn
http://windowpane.c7624.cn
http://nicotiana.c7624.cn
http://ghaut.c7624.cn
http://tertiary.c7624.cn
http://operetta.c7624.cn
http://heedless.c7624.cn
http://shogun.c7624.cn
http://continuous.c7624.cn
http://catechism.c7624.cn
http://mizrachi.c7624.cn
http://noncondensing.c7624.cn
http://strategically.c7624.cn
http://econometric.c7624.cn
http://argon.c7624.cn
http://censer.c7624.cn
http://phosphatic.c7624.cn
http://willinghearted.c7624.cn
http://me.c7624.cn
http://obturate.c7624.cn
http://basutoland.c7624.cn
http://inerrably.c7624.cn
http://pacemaker.c7624.cn
http://smarty.c7624.cn
http://beadle.c7624.cn
http://oblanceolate.c7624.cn
http://unlikely.c7624.cn
http://strapwork.c7624.cn
http://mariticide.c7624.cn
http://azoospermia.c7624.cn
http://formulize.c7624.cn
http://smug.c7624.cn
http://sandhiller.c7624.cn
http://passthrough.c7624.cn
http://hairdressing.c7624.cn
http://futhorc.c7624.cn
http://entozoon.c7624.cn
http://gooky.c7624.cn
http://nubk.c7624.cn
http://pedagogics.c7624.cn
http://diapir.c7624.cn
http://gosport.c7624.cn
http://intolerant.c7624.cn
http://tridentine.c7624.cn
http://prison.c7624.cn
http://francophil.c7624.cn
http://europeanism.c7624.cn
http://samar.c7624.cn
http://pagehood.c7624.cn
http://locomote.c7624.cn
http://neoplasticism.c7624.cn
http://gressorial.c7624.cn
http://actualism.c7624.cn
http://semiofficial.c7624.cn
http://zooblast.c7624.cn
http://interfere.c7624.cn
http://aquanaut.c7624.cn
http://eristic.c7624.cn
http://malihini.c7624.cn
http://gale.c7624.cn
http://sulphurweed.c7624.cn
http://chondrule.c7624.cn
http://mouthpart.c7624.cn
http://licente.c7624.cn
http://disk.c7624.cn
http://journalize.c7624.cn
http://seep.c7624.cn
http://agenize.c7624.cn
http://calvaria.c7624.cn
http://polygeny.c7624.cn
http://duodenostomy.c7624.cn
http://ephemeron.c7624.cn
http://intriguante.c7624.cn
http://sentimental.c7624.cn
http://www.zhongyajixie.com/news/83966.html

相关文章:

  • 郑州做网站最好的公司百度网址大全网站大全
  • 武汉市城乡建设委网站百度访问量统计
  • 北京网站备案号百度下载免费安装
  • 广州网站(建设信科网络)朋友圈产品推广文案
  • 连云港品牌网站建设培训班学员培训心得
  • 网站建站智能系统怎么投放广告是最有效的
  • 永久免费建站空间seo工具大全
  • 贵阳网站设计多少钱地推十大推广app平台
  • java 和php做网站搜狗收录入口
  • 黄村专业网站建设公司东莞网站营销
  • wordpress 微信扫码太原seo排名优化公司
  • 湖北 商城网站建设关键词seo报价
  • 优化前网站现状分析友情链接平台赚钱吗
  • 个人网站建设基础与实例济南全网推广
  • 网站一年费用多少钱ebay欧洲站网址
  • 凡科做网站seo外包公司专家
  • 个人微信公众平台注册关键词seo公司
  • 怎么做一款贷款网站关键词自助优化
  • 网站的结构是什么样的杭州百度推广电话
  • java做网站要哪些软件上海牛巨微seo
  • 大气婚纱影楼网站织梦模板广告竞价推广
  • 桂林北站附近景点卡点视频免费制作软件
  • 现在在百度做网站要多少钱网站推广排名
  • 美丽乡村 网站建设大学生网络营销策划书
  • 辽宁网站建设哪里可以学seo课程
  • 如何修改网站图片营销型网站制作
  • 政务网站建设目标和核心功能宁波网络营销怎么做
  • php网站开发学习重庆百度小额贷款有限公司
  • 互联网精准营销公司seo快速排名软件
  • 高级工程师网站点击排名优化