RubyLouvre / mmRouter

avalon的三柱臣之一( 路由,动画,AJAX)
119 stars 78 forks source link

avalon2 mmrouter如果页面存在iframe而且使用ms-attr="{src:@currPath}" 设置,点击浏览器前进后退事件BUG #110

Open Megic opened 8 years ago

Megic commented 8 years ago

html

<!DOCTYPE html>
<html>
    <head>
        <title>avalon2+mmRouter</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width">
        <script src="./dist/example1.js"></script>
    </head>
    <body ms-controller="test">
        <h1>avalon2+mmRouter</h1>
        <p>使用webpack对 avalon与mmRouter进行打包(hash模式)</p>
        <p><a href='#!/aaa'>点我</a></p>
        <p><a href='#!/bbb'>点我</a></p>
        <p>{{@currPath}}</p>
        <iframe ms-attr="{src:@currPath}" frameborder="0"></iframe>
    </body>
</html>

js

var avalon = require('avalon2')
require('../dist/mmRouter')

var vm = avalon.define({
    $id: 'test',
    currPath: ''
})
avalon.router.add("/aaa", function (a) {
    // vm.currPath = this.path
    vm.currPath='example1.html';
})
avalon.router.add("/bbb", function (a) {
    // vm.currPath = this.path
    vm.currPath='example2.html';
})

avalon.history.start({
    root: "/mmRouter"

})
avalon.scan(document.body)

image 需要点击两次,地址栏才会变动。

Megic commented 8 years ago

如果iframe不用 ms-attr="{src:@currPath}" 设置,则正常

Megic commented 8 years ago

准确来说,应该是页面iframe的src变动导致这个BUG

RubyLouvre commented 8 years ago

应该是window与iframe.window共享了历史,导致回退出问题了。这个无法解决!