docs icon indicating copy to clipboard operation
docs copied to clipboard

怎么定时刷新界面

Open wjf1547 opened this issue 3 years ago • 9 comments

怎么定时刷新界面

wjf1547 avatar Oct 29 '21 03:10 wjf1547

还有就是 滑动到界面最下面就能触发事件,有这个函数吗?

wjf1547 avatar Oct 29 '21 03:10 wjf1547

会增加布局管理器吗?

wjf1547 avatar Oct 29 '21 03:10 wjf1547

还有就是 滑动到界面最下面就能触发事件,有这个函数吗?

滑动到底部的时候会自动触发 fetch 并且带上你上一次返回的page参数

怎么定时刷新界面

使用 JavaScript 的 setInterval()设置定时器:

setInterval(() => {
    this.refresh();
}, 500)

linroid avatar Oct 29 '21 07:10 linroid

module.exports = { type: 'list', async fetch({ args, page }) { let signature = spider.myMd5() let data = await $http.post(baseUrl+"/system?action=GetNetWork",signature) data = data.data console.log(data) items = []

items.push(
  {
    title:data.title,
    style:'chips',
    actions:[
      { title:data.system},
      { title:data.time}
    ]
  }
)

setInterval(() => { this.refresh(); }, 2000) return items }

}

比如这段代码 ,setInterval应该放在哪个位置啊 放在上面这个位置,一开始是2秒,过一段时间就疯狂刷新了

wjf1547 avatar Oct 29 '21 07:10 wjf1547

module.exports = { type: 'list', async fetch({ args, page }) { let signature = spider.myMd5() let data = await $http.post(baseUrl+"/system?action=GetNetWork",signature) data = data.data console.log(data) items = []

items.push(
  {
    title:data.title,
    style:'chips',
    actions:[
      { title:data.system},
      { title:data.time}
    ]
  }
)

setInterval(() => { this.refresh(); }, 2000) return items }

}

比如这段代码 ,setInterval应该放在哪个位置啊 放在上面这个位置,一开始是2秒,过一段时间就疯狂刷新了

放在created() 里好像可以了

wjf1547 avatar Oct 29 '21 07:10 wjf1547

可以放到 created() 的生命周期方法里 https://docs.dorajs.com/#/component/lifecycle

因为 fetch() 会执行多次,所以肯定不能放这里面的

On Fri, Oct 29, 2021 at 3:32 PM wjf1547 @.***> wrote:

module.exports = { type: 'list', async fetch({ args, page }) { let signature = spider.myMd5() let data = await $http.post(baseUrl+"/system?action=GetNetWork",signature) data = data.data console.log(data) items = []

items.push(

{

title:data.title,

style:'chips',

actions:[

  { title:data.system},

  { title:data.time}

]

}

)

setInterval(() => { this.refresh(); }, 2000) return items }

}

比如这段代码 ,setInterval应该放在哪个位置啊 放在上面这个位置,一开始是2秒,过一段时间就疯狂刷新了

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Dorajs/docs/issues/13#issuecomment-954498706, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYLKTX2NAUDPZ2I5CXHDF3UJJE2RANCNFSM5G6K3SGA .

linroid avatar Oct 29 '21 07:10 linroid

滑动到底部的时候会自动触发 fetch 并且带上你上一次返回的page参数,

这句话没理解,我想传的参数再args里,page参数包含什么,有啥作用啊,有相关代码吗?

wjf1547 avatar Oct 29 '21 07:10 wjf1547

可以看下文档这里:https://docs.dorajs.com/#/component/list?id=list-%e7%bb%84%e4%bb%b6

On Fri, Oct 29, 2021 at 3:41 PM wjf1547 @.***> wrote:

滑动到底部的时候会自动触发 fetch 并且带上你上一次返回的page参数,

这句话没理解,page参数包含什么,有啥作用啊,有相关代码吗?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Dorajs/docs/issues/13#issuecomment-954503476, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYLKTWLSMMLPMW574S52M3UJJFZZANCNFSM5G6K3SGA .

linroid avatar Oct 29 '21 07:10 linroid

可以看下文档这里:https://docs.dorajs.com/#/component/list?id=list-%e7%bb%84%e4%bb%b6 On Fri, Oct 29, 2021 at 3:41 PM wjf1547 @.***> wrote: 滑动到底部的时候会自动触发 fetch 并且带上你上一次返回的page参数, 这句话没理解,page参数包含什么,有啥作用啊,有相关代码吗? — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#13 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYLKTWLSMMLPMW574S52M3UJJFZZANCNFSM5G6K3SGA . 好的

wjf1547 avatar Oct 29 '21 08:10 wjf1547