<template>
    <iframe :src="href" style="height: 100%; width: 100%; border: 0px; background-color: #fff;"></iframe>
</template>

<script>
import menuApi from '@/api/menu.js'
export default {
    name: 'component-href',
    data() {
        return {
            href: '', //外部菜单url地址
        }
    },
    beforeRouteEnter(to, from, next) {
        next((vm) => {
            // 通过 `vm` 访问组件实例
            let alias
            let routePath = vm.$route.path
            if (routePath) {
                let i = routePath.indexOf('/href')
                alias = routePath.slice(i + 1)
            }
            menuApi.getMenuByAlias(alias, (m) => {
                console.log(m)
                if (m) {
                    vm.$emit('menuChange', m)
                    vm.href = m.href
                    console.log(vm.href, m, 'm')
                }
            })
        })
    },
}
</script>
