node -v
v16.17.0
npm -v
8.15.0
npm init vue@latest
需要在初始化按照的模块可以按需按照,本次demo只取最简项目
cd michael-demo
npm install # install needed modules
npm run dev
页面效果
项目目录
{
"compilerOptions": {
// "target": "es5",
"module": "esnext",
"baseUrl": "./",
"moduleResolution": "node",
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
},
"vueCompilerOptions": {
"experimentalDisableTemplateSupport": true
}
}
还有个router存放路由相关的代码
npm install normaliza
body, h1, h2, h3, h4, ul, li {
padding: 0;
margin: 0;
}
ul, li {
list-style: none;
}
a {
text-decoration: none;
color: #333;
}
img {
vertical-align: top;
}
:root {
--primary-color: #ff9854;
/* 全局修改: 任何地方只要用到-van-tabbar-item-icon-size都会被修改掉 */
/* --van-tabbar-item-icon-size: 30px !important; */
}
body {
font-size: 14px;
}
@import "./common.css";
@import "./reset.css";
import { createRouter, createWebHashHistory } from 'vue-router'
const router = createRouter({
history: createWebHashHistory(),
// 映射关系: path -> component
routes: [
{
path: "/",
redirect: "/home"
},
{
path: "/home",
component: () => import("@/views/home/home.vue")
},
{
path: "/favor",
component: () => import("@/views/favor/favor.vue")
},
{
path: "/order",
component: () => import("@/views/order/order.vue")
},
{
path: "/message",
component: () => import("@/views/message/message.vue")
}
]
})
export default router
<template>
<div class="favor">
<h2>favor</h2>
</div>
</template>
<script setup>
</script>
<style lang="less" scoped>
</style>
<script setup>
</script>
<template>
<div>
<h2>vue</h2>
<router-view/>
</div>
<div class="app">
<div class="router-link">
<router-link to="/home">Home</router-link>
</div>
<div class="router-link">
<router-link to="/favor">Favor</router-link>
</div>
<div class="router-link">
<router-link to="/order">Order</router-link>
</div>
<div class="router-link">
<router-link to="/message">Message</router-link>
</div>
</div>
</template>
<style lang="less" scoped>
.app {
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 50px;
display: flex;
border-top: 1px solid #f3f3f3;
.router-link {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
}
</style>