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

如何利用路由router嵌套一个共用iframe的区块,当路由变化时,iframe的src跟随变化 #85

Open
EdwardQ opened this issue Dec 23, 2019 · 1 comment
Labels
block-router 路由区块

Comments

@EdwardQ
Copy link

EdwardQ commented Dec 23, 2019

No description provided.

@EdwardQ
Copy link
Author

EdwardQ commented Dec 24, 2019

ams.block('router', {
    type: 'router',
    on: {
        beforeEach: function(to, from, next) {
            ams.blocks.iframe.props.src = to.meta.src
            next()
        }
    },
    router: {
        routes: [
            {
                path: '',
                name: '首页',
                block: 'iframeBlock',
                meta: {
                    icon: 'el-icon-menu',
                    src: 'https://www.baidu.com',
                }
            }, {
                path: '/list',
                name: '测试页',
                block: 'iframeBlock',
                meta: {
                    icon: 'ams-icon-watcher',
                    src: 'https://www.vip.com'
                }
            }
        ]
    },
    blocks: {
        iframeBlock: {
            type: 'component',
            options: {
                is: 'iframe'
            },
            style: {
                position: 'absolute',
                top: 0,
                left: 0,
                width: '100%',
                height: '100%',
                border: 'none'
            },
            props: {
                src: ''
            }
        }
    }
})

@w3cmark w3cmark added the block-router 路由区块 label Jan 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
block-router 路由区块
Projects
None yet
Development

No branches or pull requests

2 participants