vue-router路由实现页面的跳转
2024-09-08 16:36:09
1、项目结构
2、定义组件
组件1 Login.vue
<template>
<form>
账号:<input type="text">
密码: <input type="text" >
</form>
</template>
<script>
export default {
name: "login"
}
</script>
<style scoped>
</style>
组件2 Main.vue
<template>
<h1>这里是主界面</h1>
</template>
<script>
export default {
name: "Main"
}
</script>
<style scoped>
</style>
3、定义路由
import Vue from 'vue'
import Router from 'vue-router'
import Main from '../components/Main'
import Login from '../components/Login'
Vue.use(Router)
export default new Router({
routes: [
{
path:'/main',
component:Main
},
{
path:'/login',
component:Login
}
]
})
4、定义首页
<template>
<div id="app">
<router-link to="/login">login</router-link>
<router-link to="/main">main</router-link>
<h1>大家好</h1>
<router-view/>
</div>
</template>
<script>
export default {
name: 'App'
}
</script>
<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
5、效果展示
最新文章
- 2-ser2003系统封装实验报告
- Android Studio Gradle 问题 解决方案
- 采用CSS3设计的登陆界面
- Matlab 2012a 下载和安装教程
- find your present
- jQuery.fn.extend与jQuery.extend 的区别
- Eclipse-----jrebel实现jetty热部署
- pie.htc 在IE下不起作用~~~
- phpcms的验证码替换 及 phpcms实现全站搜索功能
- [学习OpenCV攻略][016][RedHat下安装OpenCV]
- js的call和apply区别
- ES6 实战项目构建 ES6+glup+express
- NumPy学习_01 ndarray相关概念
- project 2013 设置工期为1个工作日,但开始时间与结束时间不是同一天
- LIght OJ 1179
- 分布式监控系统Zabbix-批量添加聚合图形
- HDU.5909.Tree Cutting(树形DP FWT/点分治)
- kettle学习
- Vue -- webpack 项目自动打包压缩成zip文件
- android 打开系统相机,
热门文章
- 高效能团队的Java研发规范(进阶版)
- Taurus.MVC 微服务框架 入门开发教程:项目部署:2、让Kestrel支持绑定多个域名转发,替代Ngnix使用。
- CF593D Happy Tree Party(不用树剖)
- HDU2065 “红色病毒”问题 (指数型母函数经典板题)
- wallpaperPKG文件提取
- RestTemplate用法
- R数据分析:用R建立预测模型
- echarts学习笔记(一)
- Linux虚拟机启动报错挂载点丢失
- C++基础入门:C++初始