{"action":"created","issue":{"url":"https://api.github.com/repos/weui/weui/issues/26","labels_url":"https://api.github.com/repos/weui/weui/issues/26/labels{/name}","comments_url":"https://api.github.com/repos/weui/weui/issues/26/comments","events_url":"https://api.github.com/repos/weui/weui/issues/26/events","html_url":"https://github.com/weui/weui/issues/26","id":111951649,"number":26,"title":"Router in wechat webview","user":{"login":"Huxpro","id":5563315,"avatar_url":"https://avatars.githubusercontent.com/u/5563315?v=3","gravatar_id":"","url":"https://api.github.com/users/Huxpro","html_url":"https://github.com/Huxpro","followers_url":"https://api.github.com/users/Huxpro/followers","following_url":"https://api.github.com/users/Huxpro/following{/other_user}","gists_url":"https://api.github.com/users/Huxpro/gists{/gist_id}","starred_url":"https://api.github.com/users/Huxpro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Huxpro/subscriptions","organizations_url":"https://api.github.com/users/Huxpro/orgs","repos_url":"https://api.github.com/users/Huxpro/repos","events_url":"https://api.github.com/users/Huxpro/events{/privacy}","received_events_url":"https://api.github.com/users/Huxpro/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-17T08:53:53Z","updated_at":"2015-10-19T09:50:46Z","closed_at":null,"body":"Hey, nice work guys.\r\n\r\n我注意到你们使用 `history.pushState()` 实现了简单的路由，我在微信 webview 中测试了一下，有一个问题有点奇怪：**使用微信 webview 上方的 Back 和使用“屏幕边缘左滑返回” 的效果完全不一样**\r\n\r\n当使用 Webview Back 时，所有的路由都很正常\r\n但当通过屏幕边缘左滑返回时，路由好像失效了，直接退出了整个 webview。\r\n\r\n我发现好像所有使用 `pushState` 实现路由的 web app 都有这个问题，\r\n但是使用原始的 `locatin.hash` & `hashchange` 做路由的却没有这个问题……\r\n\r\n但是它们确实都给 `history.length` +1 了……\r\n是微信 webview 做了什么处理吗？还是 `pushState` 的表现在 iOS WebView 上本来有有不同？（Safari 是没有这个问题的）\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/weui/weui/issues/comments/149169262","html_url":"https://github.com/weui/weui/issues/26#issuecomment-149169262","issue_url":"https://api.github.com/repos/weui/weui/issues/26","id":149169262,"user":{"login":"progrape","id":4652816,"avatar_url":"https://avatars.githubusercontent.com/u/4652816?v=3","gravatar_id":"","url":"https://api.github.com/users/progrape","html_url":"https://github.com/progrape","followers_url":"https://api.github.com/users/progrape/followers","following_url":"https://api.github.com/users/progrape/following{/other_user}","gists_url":"https://api.github.com/users/progrape/gists{/gist_id}","starred_url":"https://api.github.com/users/progrape/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/progrape/subscriptions","organizations_url":"https://api.github.com/users/progrape/orgs","repos_url":"https://api.github.com/users/progrape/repos","events_url":"https://api.github.com/users/progrape/events{/privacy}","received_events_url":"https://api.github.com/users/progrape/received_events","type":"User","site_admin":false},"created_at":"2015-10-19T09:50:46Z","updated_at":"2015-10-19T09:50:46Z","body":"@Huxpro 这个问题我们也留意到的，只是没有去深究。今天咨询了客户端开发的同事，**屏幕边缘左滑返回**，是实现监听了WebView的[webView:shouldStartLoadWithRequest:navigationType:](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIWebViewDelegate_Protocol/#//apple_ref/occ/intfm/UIWebViewDelegate/webView:shouldStartLoadWithRequest:navigationType:)事件，触发了这个事件就会做类似于`history.lenght + 1`的操作，然后就可以**屏幕边缘左滑返回**。\r\n\r\n调试发现，`location.href`和`location.hash`这两种方式都可以触发到该事件，然而`pushState`却没有触发，因此`pushState`后滑动，就直接关闭了WebView了"}}