<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<style>
*{padding: 0;margin: 0;}
ul{
display: flex;
list-style: none;
position: absolute;
bottom: 0;
left: 0;
right: 0;
justify-content:space-between;
height: 60px;
}
li{
background: royalblue;
width: 33%;
display: flex;
align-items: center;
justify-content: center;
}
</style>
<script src="../vue.js"></script>
<div id="app">
<!-- <keep-alive>标签:保留状态避免重新渲染-->
<!-- <component>标签:元素,动态地绑定多个组件到它的is属性 -->
<keep-alive>
<component :is="isShow"></component>
</keep-alive>
<ul>
<li @click="handleHomeClick">首页</li>
<li @click="handleListClick">列表页</li>
<li @click="handleShopcarClick">购物车页</li>
</ul>
</div>
<script>
new Vue({
el: "#app",
components: {//局部组件
home:{
template:`<div>home<input type="text"></div>`
},
list:{
template: `<div>list</div>`
},
shopcar:{
template: `<div>shopcar</div>`
},
},
data: {
isShow:"home"
},
methods: {
// 改变 is属性
handleHomeClick() {
this.isShow = "home"
},
handleListClick() {
this.isShow = "list"
},
handleShopcarClick() {
this.isShow = "shopcar"
}
},
})
</script>
</body>
</html>

效果图