mmRouter icon indicating copy to clipboard operation
mmRouter copied to clipboard

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

Open Megic opened this issue 9 years ago • 3 comments

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 avatar Sep 06 '16 03:09 Megic

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

Megic avatar Sep 06 '16 03:09 Megic

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

Megic avatar Sep 06 '16 03:09 Megic

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

RubyLouvre avatar Sep 07 '16 06:09 RubyLouvre