新建文件夹,使用编辑器打开
使用vue init webpack tabbar
创建Tabbar组件,写入html布局以及css样式
<template>
<div id="tab-bar">
<div class="tab-bar-item">首页</div>
<div class="tab-bar-item">分类</div>
<div class="tab-bar-item">购物车</div>
<div class="tab-bar-item">我的</div>
</div>
</template>
<script>
export default {
name: "tabbar"
}
</script>
<style scoped>
#tab-bar{
display: flex;
background-color: #f6f6f6;
position: fixed;
left: 0;
right: 0;
bottom: 0;
box-shadow: 0 -3px 1px rgba(100,100,100,.08);
}
.tab-bar-item{
flex:1;
text-align: center;
height:49px;
}
</style>
在app.vue中:
import TabBar from './components/tabbar/TabBar'
components: {
TabBar
}
<tab-bar></tab-bar> <!--3.使用-->