weex icon indicating copy to clipboard operation
weex copied to clipboard

setInterval在集成到android后失去效用,但在playground可正常运行,求救!(附代码)

Open MARCUSW10 opened this issue 10 years ago • 13 comments

<template> <div> <div if="{{flag1}}" style="background-color:#FFFAFA;height:1350px;" > <image style="width:780px;height:600px;opacity:{{opacitys}};" src="http://s6.sinaimg.cn/mw690/0023IuTRzy76x8fmVbn25&690"></image> </div>
</div> </template> <script> require('weex-components'); var timer; module.exports={ data:{ opacitys:1, }, ready:function(){ var t=setInterval(this.changeopa.bind(this),1000); }, methods:{ changeopa:function(){ this.opacitys=this.opacitys-0.2; var $modal = require('@weex-module/modal'); $modal.toast({'message': 'change'+this.opacitys, duration:1}); } }

}

</script>

MARCUSW10 avatar Nov 25 '16 00:11 MARCUSW10

这个问题是因为 内部Handler 产生的 混乱导致的。恢复这个问题只需要 杀掉app的进程重新进入就可以了。

haicuan139 avatar Nov 25 '16 01:11 haicuan139

还是不行,不管是杀死进程,还是重新启动手机,setInterval还是无法起作用,求救啊!

MARCUSW10 avatar Nov 25 '16 01:11 MARCUSW10

那你试试 在setInterval 中调用this._app.updateActions();

haicuan139 avatar Nov 25 '16 01:11 haicuan139

就是在你调用setInterval 执行完成逻辑 变更data 的最后 调用this_app.updateActions();

haicuan139 avatar Nov 25 '16 01:11 haicuan139

如果再不行的话 请删除sdk 重新下载!

haicuan139 avatar Nov 25 '16 01:11 haicuan139

你的意思是写成这样吧 ready:function(){ var t=setInterval(this.changeopa.bind(this),1000); this_app.updateActions(); }

MARCUSW10 avatar Nov 25 '16 01:11 MARCUSW10

rady:function(){

setInterval(function(){ this.count ++; this_app.updateActions(); }.bind(this),1000) }

haicuan139 avatar Nov 25 '16 01:11 haicuan139

使用完interval记得 clear

haicuan139 avatar Nov 25 '16 01:11 haicuan139

是要删除weex文件夹里面的android的sdk吗

MARCUSW10 avatar Nov 25 '16 02:11 MARCUSW10

如果playground 可以的话 说明代码没有问题。建议你把sdk 升级到最新版本试试。

haicuan139 avatar Nov 25 '16 02:11 haicuan139

加入要删除sdk,是吧sdk mananger里面安装的全删了,再重装吗

MARCUSW10 avatar Nov 25 '16 03:11 MARCUSW10

@MARCUSW10 请问你那儿setInterval失效的问题还存在吗? 如果还是有问题我们可以安排专门的同学和你一起排查一下。

alext1981 avatar Dec 09 '16 17:12 alext1981

长时间无后续讨论,先关掉了 感谢理解

Jinjiang avatar Dec 27 '16 16:12 Jinjiang