能否给出改进后完整代码
时间: 2024-09-10 21:10:12 浏览: 42
当然,以下是改进后的HTML与Vue组件(Index.vue)代码:
### Index.html
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>资源加载中</title>
<script type="text/javascript" src="https://api.map.baidu.com/api?v=3.0&ak=ViqwC0oIAy5oAXcKCB8StCqIqsoR255u"></script>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= webpackConfig.name %></title>
<!--[if lt IE 11]>
<script>window.location.href='/html/ie.html';</script>
<![endif]-->
<style>
/* 页面样式 */
html, body, #app {
height: 100%;
margin: 0;
padding: 0;
}
#loader-wrapper {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 999999;
}
#loader {
display: block;
position: relative;
left: 50%;
top: 50%;
width: 150px;
height: 150px;
margin: -75px 0 0 -75px;
border-radius: 50%;
border: 3px solid transparent;
border-top-color: #FFF;
animation: spin 2s linear infinite;
z-index: 1001;
}
#loader::before, #loader::after {
content: "";
position: absolute;
top: 5px;
left: 5px;
right: 5px;
bottom: 5px;
border-radius: 50%;
border: 3px solid transparent;
border-top-color: #FFF;
animation: spin 3s linear infinite;
}
#loader::after {
top: 15px;
left: 15px;
right: 15px;
bottom: 15px;
animation: spin 1.5s linear infinite;
}
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.loader-section {
position: fixed;
top: 0;
width: 51%;
height: 100%;
background: #7171C6;
z-index: 1000;
transform: translateX(0);
}
.section-left {
left: 0;
}
.section-right {
right: 0;
}
.loaded .loader-100%);
transition: all 0.7s 0.3s cubic-bezier(0.645, 0.045, 0.355, 1.000);
}
.loaded .loader-section.section-right {
transform: translateX(100%);
transition: all 0.7s 0.3s cubic-bezier(0.645, 0.045, 0.355, 1.000);
}
.loaded #loader {
opacity: 0;
transition: all 0.3s ease-out;
}
.loaded #loader-wrapper {
visibility: hidden;
transform: translateY(-100%);
transition: all 0.3s 1s ease-out;
}
.no-js #loader-wrapper {
display: none;
}
.no-js h1 {
color: #222222;
}
.load_title {
font-family: 'Open Sans';
color: #FFF;
font-size: 19px;
width: 100%;
text-align: center;
z-index: 9999999999999;
position: absolute;
top: 60%;
opacity: 1;
line-height: 30px;
}
.load_title span {
font-weight: normal;
font-style: italic;
font-size: 13px;
color: #FFF;
opacity: 0.5;
}
</style>
</head>
<body>
<div id="app">
<div id="loader-wrapper">
<div id="loader"></div>
<div class="loader-section section-left"></div>
<div class="loader-section section-right"></div>
<div class="load_title">正在加载系统资源,请耐心等待</div>
</div>
</div>
<div id="mapCon" style="width: 100%; height: 500px;"></div>
<script>
var map = new BMap.Map('mapCon');
map.centerAndZoom(new BMap.Point(111.71969711763904, 40.805194188989994), 15);
map.addControl(new BMap.MapTypeControl({ mapTypes: [BMAP_NORMAL_MAP, BMAP_HYBRID_MAP] }));
map.addOverlay(new BMap.Marker(new BMap.Point(111.71969711763904, 40.805194188989994)));
map.enableScrollWheelZoom(true);
</script>
</body>
</html>
```
### Index.vue
```vue
<template>
<div class="app-container home">
<h1>智慧社区平台</h1>
<div id="mapCon" style="width: 100%; height: 500px;"></div>
</div>
</template>
<script>
export default {
name: "Index",
data() {
return {
version: "3.8.8"
};
},
methods: {
goTarget(href) {
window.open(href, "_blank");
}
}
};
</script>
```
这个版本的代码包含了一个基本的页面结构,并且引入了百度地图API以展示一个简单的地图。同时在HTML文件中定义了一些CSS样式来增强用户体验,例如加载指示器。此外,在Vue组件中也定义了基础的数据模型以及方法。
阅读全文