[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
1> router-link跳转
1>不带参数 <router-link :to="{name:'home'}"> <router-link :to="{path:'/home'}">
/** * name&&path都行,建议使用name * router-link 中链接如果是 '/' 开始就是根路由开始,如果不带 '/'
则从当前路径开始 */ 2>带params参数 <router-link :to="{name:'home',params:{id:123}"> /** *
params传参数(类似post) * 路由配置 path:'/home/:id' 或 path:'/home:id' *
不配置path,第一次可请求,刷新页面id会消失,配置path,刷新页面id会保留 * html 取参 $route.params.id script 取参
this.$route.params.id */ 3>带query参数 <router-link
:to="{name:'home',query:{id:123}"> /** * query传参数,(类似get,url会显示参数) * 路由不可配置 *
html 取参 $route.query.id script取餐 this.$route.query.id */
2>this.$route.push()
1. 不带参数 this.$router.push('/home') this.$router.push({name:'home'})
this.$router.push({path:'/home'}) 2. query传参
this.$router.push({name:'home',query: {id:'123456'}})
this.$router.push({path:'/home',query: {id:'123456'}}) // html 取参
$route.query.id script 取参 this.$route.query.id 3. params传参
this.$router.push({name:'home',params: {id:'123456'}}) // 只能用 name // 路由配置
path: "/home/:id" 或者 path: "/home:id" , // 不配置path ,第一次可请求,刷新页面id会消失 //
配置path,刷新页面id会保留 // html 取参 $route.params.id script 取参 this.$route.params.id 4.
query和params区别 query类似get, 跳转之后页面url后面会拼接参数,类似?id=123456, 非重要性的可以这样传,
密码之类还是用params刷新页面id还在 params类似post, 跳转之后页面url后面不会拼接参数, 但是刷新页面id会消失。