关于html内嵌vuejs使用iframe无法加载vue实例解决方案,使用bootstrap再iframe

描述:html内嵌vuejs,manage页面也采用vue进行iframe跳转,这个时候无法加载vue实例。具体原因不明,解决方案如下:bootstrap做管理页面,再通过iframe加载html内嵌vue的页面

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Management Dashboard with Bootstrap</title>
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        /* Custom styles for main content */
        #main-content {
            padding: 20px;
            overflow: hidden; /* Hide scrollbar */
            position: relative; /* Required for absolute positioning inside */
        }

        /* Style for iframe */
        #main-iframe {
            width: 100%;
            height: 100%;
            border: none;
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            overflow-y: auto; /* Enable scrolling */
            padding-right: 17px; /* Compensate for scrollbar width */
            box-sizing: content-box; /* Adjust content box for padding-right */
        }

        /* Custom styles for sidebar */
        #sidebar {
            background-color: #343a40; /* Dark background color */
            color: #f8f9fa; /* Light text color */
            height: 100vh; /* Full height */
            position: sticky;
            top: 0;
            overflow-y: auto; /* Enable scrolling */
            padding-top: 20px; /* Padding at the top */
        }

        /* Sidebar title */
        #sidebar .sidebar-title {
            font-size: 1.2rem;
            font-weight: bold;
            text-align: center;
            margin-bottom: 20px;
        }

        /* Sidebar links */
        #sidebar ul {
            list-style-type: none;
            padding-left: 0;
        }

        #sidebar ul li {
            margin-bottom: 1rem;
        }

        #sidebar ul li a {
            color: #f8f9fa; /* Link text color */
            text-decoration: none;
            display: block;
            padding: 0.5rem;
            transition: background-color 0.3s;
        }

        #sidebar ul li a:hover {
            background-color: #495057; /* Darker background on hover */
        }
    </style>
</head>
<body>
<div class="container-fluid">
    <div class="row">
        <!-- Sidebar -->
        <nav id="sidebar" class="col-md-3 col-lg-2 d-md-block">
            <div class="position-sticky">
                <!-- Sidebar Title -->
                <div class="sidebar-title">招聘管理</div>

                <!-- Sidebar Links -->
                <ul class="nav flex-column">
                    <li class="nav-item">
                        <a class="nav-link active" href="#" onclick="loadPage('tb_applicants_info.html')">浏览应聘信息</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link active" href="#" onclick="loadPage('tb_applicants.html')">应聘管理</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#" onclick="loadPage('tb_talent_pool.html')">浏览人才库</a>
                    </li>
                </ul>
            </div>
        </nav>

        <!-- Main Content Area -->
        <main id="main-content" class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
            <iframe id="main-iframe" src="" frameborder="0"></iframe>
        </main>
    </div>
</div>

<!-- Bootstrap JS (optional, for certain components) -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>

<script>
    function loadPage(pageUrl) {
        document.getElementById('main-iframe').src = pageUrl;
    }
</script>

</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值