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

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

bash 复制代码
<!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>
相关推荐
Yyyyyy~2 分钟前
【java】运算符
java
博界IT精灵10 分钟前
C语言中的数据类型及其转换
c语言·开发语言
古法安卓11 分钟前
Android-切换白天黑夜内存不足问题排查
android·java·android studio
软件黑马王子12 分钟前
13.缓存池优化:对象上限配置
开发语言·前端框架·c#
Dreams_l18 分钟前
如何保证RabbitMQ消息可靠传输
java·rabbitmq·java-rabbitmq
MacroZheng20 分钟前
面试官皱眉:"你懂 Vibe Coding,那你说superpowers和grill-me怎么选?",我:"小孩才做选择,我全都要!"
java·人工智能·后端
大模型码小白22 分钟前
【AI大模型】DeepSeek Harness 深度解析:大模型评测框架的架构与实践
java·运维·人工智能·spring·架构·自动化
Mr.Java.28 分钟前
本地测试全绿,上线 SQL 报错?Spring Boot 容器级 DT 测试实战指南(附Skills)
java·测试用例·springboot·testcontainers·dt·java测试skills·dt测试
李迟36 分钟前
Golang实践录:工程框架实践:搭建工程模板
开发语言·后端·golang
纪伊路上盛名在36 分钟前
Kabsch算法的Julia实现
开发语言·算法·julia·序列分析·蛋白质·rmsd