CNode

ratchet-practice

分享
Ii5ting发布于11 年前最后回复11 年前2 回复3343 浏览0 收藏

twitter ratchet framework's practice

https://github.com/i5ting/ratchet-practice

这是我很早之前写的一篇,又在用ratchet,发出来和大家分享一下

欢迎关注我的公众号【node全栈】 node全栈.png

查看回复

回复 (2)

I
i5ting#1·11 年前
I
i5ting#2·11 年前

补充一点

push事件

当多个页面push和pop的时候,可能需要更新数据,此时需要监听push事件

	window.addEventListener('push', function(e){
		var url = e.detail.state.url;

		if(case_one(url,/chat\.html/g)){
			// alert("聊天");
			init_with_chat();
		}
		
		if(case_one(url,/index\.html/g)){
			// alert("首页");
			// $('.content').html(index_content)
			// main();
		}
		
		function case_one(url, pattern){
			return (url.match(pattern)) instanceof Array;
		}
	});
参与回复
登录后即可参与回复。登录