关于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>
相关推荐
这个需求做不了1 分钟前
Java实现文件格式转换(图片,视频,文档,音频)
java
星融元asterfusion1 分钟前
AsterNOS SONiC基于YANG模型的现代网络管理:从CLI到gNMI的演进
开发语言·sonic·yang
web3.08889993 分钟前
1688商品详情API接口深度解析
开发语言·python
愿你天黑有灯下雨有伞5 分钟前
高性能Java并发编程:如何优雅地使用CompletableFuture进行异步编排
java
indexsunny6 分钟前
互联网大厂Java面试实战:基于电商场景的Spring Boot与微服务技术问答
java·spring boot·微服务·面试·hibernate·电商场景·技术问答
qq_12498707537 分钟前
基于Spring Boot的电影票网上购票系统的设计与实现(源码+论文+部署+安装)
java·大数据·spring boot·后端·spring·毕业设计·计算机毕业设计
欧阳天风8 分钟前
用setTimeout代替setInterval
开发语言·前端·javascript
无心水9 分钟前
【分布式利器:腾讯TSF】6、TSF可观测性体系建设实战:Java全链路Metrics+Tracing+Logging落地
java·分布式·架构·wpf·分布式利器·腾讯tsf·分布式利器:腾讯tsf
散峰而望9 分钟前
【算法竞赛】顺序表和vector
c语言·开发语言·数据结构·c++·人工智能·算法·github
小鸡脚来咯11 分钟前
Java字符串详解
java·开发语言