当前位置:网站首页>router和keep-alive
router和keep-alive
2022-07-17 00:06:00 【静止呀】
router的使用
this.$router.replace('/home'),无法前进后退。
this.$router.push('/home') 可以前进后退
// 路由的全局对象,包含所有的路由对象
console.log(this.$router)
// 当前活跃对象
console.log(this.$route)
// 点击函数中router携带参数
this.$router.replace({
path: '/profile',
query: {
name:'liu',
age:'22',
height:'157'
}
})
router-link组件支持用户在具有路由功能的应用中点击导航。通过to属性指定目标地址.
// router-link 加 replace 和不加的区别。
// 在不加replace的时候,网址是可以通过箭头前进和后退的。说明前进后退用的pushState。改成repalceState后,就不可以通过箭头前进和后退了。
<router-link to="/home" replace>首页</router-link>
// 标签router-link 传递参数的情况
<router-link :to="{
path: '/profile',
query: {
name:'liu',age:'22',height:'157'}
}" replace>档案</router-link>
keep-alive组件
keep-alive是Vue内置的额一个组件,可以使被包含的组件保留状态,或避免重新渲染。
keep-alive两个属性: include(字符串或者正则表达式,只有匹配的组件会被缓存) exclude(字符串或者正则表达式,任何匹配的组件都不会被缓存) 不能加空格。
created与destroyed钩子:created和destroyed,在没有加keep-alive之前,这两个回调函数在每次载入离开该组件都会被重复加载,加了以后就只有第一次载入离开会被触发。
router-view是一个组件, 如果将其包在keep-alive里面,所有路径匹配到的视图组件都会被缓存。意思就是路由跳转指向的页面将会显示在router-view中。
<keep-alive exclude="">
<router-view></router-view>
</keep-alive>
keep-alive include="">
<router-view></router-view>
</keep-alive>
边栏推荐
猜你喜欢

使用bat自动执行cmd命令(多个命令或单个命令)
![Eye of depth III - (6)] mathematics: matrix diagonalization and quadratic form 1](/img/6f/079f9d39b560a31fe3a0b57e0ff5aa.png)
Eye of depth III - (6)] mathematics: matrix diagonalization and quadratic form 1

js截取字符串前几位或者截取字符串后几位

uni-app微信小程序——商城(8)——订单详情

Express项目创建以及其路由介绍
![[GFCTF 2021]Baby_ Cve-2021-41773 on the web](/img/e0/7541860509b3b77f758447e377f2f7.png)
[GFCTF 2021]Baby_ Cve-2021-41773 on the web

How to modify the color of a line of text in the elemtnui table (elemtnui table modifies the color of a line of text)

Uni app wechat applet - Mall (3) - Mall Homepage

微信推送-模版消息参数配置

页面布局——三栏布局解决方式
随机推荐
Single page application spa and multi page application MPa
Day14 view set and route
服务器如何安装宝塔面板?(宝塔面板安装教程)
elemtnui 表格如何修改某行文字颜色(elemtnui table 修改某行文字颜色)
C Programming Language (2nd Edition)--读书笔记--1.3
(三)传递参数
当 std::bind 遇上 this
es6 map提取数组对象
uni-app微信小程序——商城(6)——我的主页
Day16 sorting, current limiting
C Programming Language (2nd Edition)--读书笔记--1.4
Day07 ORM table relationship and operation
(九)Shell 输入输出重定向
今天的码农女孩学习了关于nodejs和REPL 交互式解释器的知识
[elementui El date picker date selector, the end time must not be earlier than the start time, and only the date of the specified number of days from the start time can be selected]
Text indent in uniapp doesn't work, and the indentation in the first line of uniapp doesn't work. How to solve it?
The C Programing Language-2nd--笔记--4.11.3
(八)Shell函数
自己封裝的風格化的開關卡片組件
Node的数据库编程(MySQL),增删改查