Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

页面多起来后,数据管理有什么好的方式去实现? #44

Closed
CommanderXL opened this issue Sep 14, 2016 · 13 comments
Closed

Comments

@CommanderXL
Copy link

你好,我看整个framework在进行视图切换的会异步加载相应的视图资源文件。

然后生成DOM结构插入到页面当中,然后进行页面的切换。我看整个的页面当中,一旦新页面插入到页面当中后,是不被销毁的。如果页面一旦多起来,那么数据管理有什么好的方式去实现呢?

@zhaoda
Copy link
Owner

zhaoda commented Sep 14, 2016

@zhaoda
Copy link
Owner

zhaoda commented Sep 14, 2016

@CommanderXL 看这个Issue #22

@nicklao
Copy link

nicklao commented Sep 19, 2016

@zhaoda 使用 $doc.trigger('spa:viewcachecount', {count: 2});
当view达到2个后就报错了!
cleanupcache[cleanupkey].html('').remove();
Uncaught TypeError: Cannot read property 'html' of undefined

@zhaoda
Copy link
Owner

zhaoda commented Sep 19, 2016

@nicklao 你用的DOM库是jQuery还是Zepto,什么版本?

@zhaoda
Copy link
Owner

zhaoda commented Sep 19, 2016

@nicklao 我在 ~/docs 里增加了设置页面缓存的事例,测试没有问题,spa.js 也增加不能设置缓存数量为1的容错。5f3ca3e

@nicklao
Copy link

nicklao commented Sep 19, 2016

我用的是 jq 3.x 版本的

@zhaoda
Copy link
Owner

zhaoda commented Sep 19, 2016

jQuery 3.x 是最新的版本,我没测试过兼容问题,先换成 2.x 版本试试吧

@nicklao
Copy link

nicklao commented Sep 19, 2016

用回jQ 2.x 后,还是报了一样的错。这应该和JQ没关系了。和你的DEMO不同的是,我的路由配置上有要带参数的,会否有影响呢?
#detail/info/%E5%8C%BB%E7%94%9F%E7%AE%80%E4%BB%8B/:0
只要是从这路由回退(goBack)的话,就会报那error了

@zhaoda
Copy link
Owner

zhaoda commented Sep 19, 2016

@nicklao 等我明天看看吧,我们之前的项目设置这个问题,但是中间又经过了一些修复,也可能造成了bug,你也空也可以debug一下spa的源代码看看。

@nicklao
Copy link

nicklao commented Sep 20, 2016

@zhaoda 找到bug所在了,
cleanupsplit = value.split(':', 2) 以":"分号作为分割的话,如果遇上:keyword会有“:”分号的话,就像我路由传参的一样,参数就会被split了,这里应该修改为,只split第一个“:”便可解决了!

zhaoda added a commit that referenced this issue Sep 20, 2016
@zhaoda
Copy link
Owner

zhaoda commented Sep 20, 2016

@nicklao 我修复了,你看看 32d7019

@zhaoda zhaoda closed this as completed Sep 20, 2016
@nicklao
Copy link

nicklao commented Sep 20, 2016

@zhaoda ok, fix了!是能清view dom上的资源。 如果能把对应的 module 里的 object 引用也清了,回收内存就更好了!呵呵呵!

@zhaoda
Copy link
Owner

zhaoda commented Sep 20, 2016

@nicklao 你的想法不错,欢迎一起来维护SPA,提交PR。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants