当前位置: 首页 > news >正文

Vue极简入门

1.注册路由,如果是子路由,就加一个children

import Vue from 'vue'
import Router from 'vue-router'
import Main from '../views/Main.vue'
import Login from '../views/Login.vue'import UserProfile from "../views/user/Profile.vue"
import UserList from "../views/user/List.vue"Vue.use(Router)export default new Router({routes: [{path: '/login',name: 'login',component: Login},{path: '/main',name: 'main',component: Main,children:[{path:'/user/profile',component:UserProfile},{path:'/user/list',component:UserList},]}]
})

2.使用方法

显示的页面

显示的位置

<template><div><h1>Main</h1><router-link to="/user/profile">个人信息</router-link><router-link to="/user/list">用户列表</router-link><router-view></router-view></div>
</template><script>export default{name:"Main"}
</script><style scoped></style>

3.name 传组件名 params 传递参数 需要对象 v-bind 而后path接收数据

<template><div><h1>Main</h1><router-link :to="{name:'UserProfile',params:{id:1}}">个人信息</router-link><router-link to="/user/list">用户列表</router-link><router-view></router-view></div>
</template><script>export default{name:"Main"}
</script><style scoped></style>
import Vue from 'vue'
import Router from 'vue-router'
import Main from '../views/Main.vue'
import Login from '../views/Login.vue'import UserProfile from "../views/user/Profile.vue"
import UserList from "../views/user/List.vue"Vue.use(Router)export default new Router({routes: [{path: '/login',name: 'login',component: Login},{path: '/main',name: 'main',component: Main,children:[{path:'/user/profile/:id',name:'UserProfile',component:UserProfile},{path:'/user/list',component:UserList},]}]
})

3.1展示 {{ $route.params.id }}

<template><div><h1>个人信息</h1>{{ $route.params.id }}</div></template><script>
export default{name:"UserProfile"
}
</script><style scoped></style>
http://www.lryc.cn/news/446274.html

相关文章:

  • 系统敏感信息搜索工具(支持Windows、Linux)
  • Fyne ( go跨平台GUI )中文文档-容器和布局 (四)
  • 文心智能体 恐怖类游戏
  • 智慧城市运营模式--政府和社会资本合作
  • 【Python报错已解决】ValueError: cannot convert float NaN to integer
  • ClickHouse 与 Quickwit 集成实现高效查询
  • Facebook Marketplace无法使用的原因及解决方案
  • uboot — uboot命令的使用
  • 基础漏洞——SSRF
  • 报错解决方案
  • 机器人的动力学——牛顿欧拉,拉格朗日,凯恩
  • 【AI写作】解释区块链技术的应用场景和优势
  • IPsec-Vpn
  • 一日连发两款视频大模型,火山引擎杀疯了!
  • JavaScript --数字Number的常用方法
  • GIS开发常用的开源地图数据框架有哪些?
  • SPSS26统计分析笔记——2 描述统计
  • C++——输入一个字符串,把其中的字符按逆序输出。如输入LIGHT,输出THGIL。用string方法。
  • 基于区块链的相亲交易系统源码解析
  • win11 wsl2安装ubuntu22最快捷方法
  • jekyll相关的技术点
  • 【Golang】Go语言中如何面向对象?
  • E2VPT: An Effective and Efficient Approach for Visual Prompt Tuning
  • 影刀RPA实战:网页爬虫之天猫商品数据
  • 微信小程序注册流程及APPID获取(完整版图文教程)
  • 分享课程:VUE数据可视化教程
  • Flink的反压机制:底层原理、产生原因、排查思路与解决方案
  • Unity DOTS系列之Aspect核心机制分析
  • webpack 的打包target讲解 node环境打包下的文件存储造成不易察觉的坑点
  • JVM面试问题集