vue传参
<template>
<ul>
<li v-for="item in list" :key="item.id">
<button @click="goDetail(item.id)">
{{item.name}}
</button>
</li>
</ul>
</template>
<script>
export default {
data(){
return{
list:[]
}
},
created(){
this.getData(this.$route.params.type); //$route 才有params 动态路由。
},
methods:{
goDetail(id){
this.$router.push({name:'detail',params:{id:id}}) //哪里需要detail页面哪里就可以 $router的才能push detail。
},
getData(type){
this.$http.get('http://localhost:3000/'+type).then((res)=>{
this.list = res.data;
})
}
},
watch:{
$route(new,old){
this.getData(new.params.type); //所有再实例上挂载的属性都可以进行监听
}
}
}
</script>
vue传参的更多相关文章
- vue传参页面刷新数据丢失问题
在做vue的时候,经常会遇到组件之间数据的传递问题,通过params或者query传参,但是,当页面刷新的时候,数据会丢失,找不到数据.今天经过总结,解决了这个问题.通过了一下几种情况进行传值: 通过 ...
- vue传参方式
//query传参,使用name跳转 this.$router.push({ name:'second', query: { queryId:'201808 ...
- vue传参子传父
vue子传父用$emit实现 1.文件目录结构 2.parent父组件内容 <template> <div class="wrap"> <div> ...
- vue 传参props里面为什么要带type,还有default?
这个是子组件啦 ,写type的意思是swiperDate传过来的数据类型是数组,default就是表示不传默认返回的[ ],空数组. 这种就是表示传的数据类型是number,不传默认是0.
- vue 传参动态
方法一: router/index.js { path: '/src/views/activitiesDetails', name: activitiesDetails, component: act ...
- vue传参二
<template> <ul> <li v-for="(value,key,index) in list" :key="index" ...
- vue的传参方式和router使用技巧
vue传参方法一 1,路由配置 { path: '/describe/:id', name: 'Describe', component: Describe } 2,使用方法 // 直接调用$rout ...
- Vue-router的传参方式和router使用技巧
vue传参方法一 1,路由配置 { path: '/describe/:id', name: 'Describe', component: Describe } 2,使用方法 // 直接调用$rout ...
- vue.js 1中父组件跳到子组件中并传参让子组件显示不同的内容
父组件中的点击跳转: <ul class="insurance-entry clearfloat"> <li v-link="{name:'produc ...
随机推荐
- February 12th, 2018 Week 7th Monday
One man's fault is another man's lesson. 前车之覆,后车之鉴. We make mistakes every day, large or small, fail ...
- Eric Chen Mock Interview
Given an array with integers. Find two non-overlapping subarrays A and B, which |SUM(A) - SUM(B)| is ...
- 《Java大学教程》—第15章 异常
自测题:1. 什么是异常?P357异常是在程序生命周期内出现的事件,它会导致程序行为不可靠. 2. 已检查异常和未检查异常的区别是什么?P359在编译器允许程序被编译通过前,要求程序员必须编写代 ...
- linux快速搭建
------------------------------------------ 转载内容 --------------------- Linux升级命令有两个分别是yum upgrade和yum ...
- 5.01-requests_auth
import requests # 发送post请求 data = { } response = requests.post(url, data=data) # 内网 需要 认证 auth = (us ...
- 机器学习算法总结(四)——GBDT与XGBOOST
Boosting方法实际上是采用加法模型与前向分布算法.在上一篇提到的Adaboost算法也可以用加法模型和前向分布算法来表示.以决策树为基学习器的提升方法称为提升树(Boosting Tree).对 ...
- Python-wxpy继承关系
聊天对象 通过机器人对象 Bot 的 chats(), friends(),groups(), mps() 方法, 可分别获取到当前机器人的 所有聊天对象.好友.群聊,以及公众号列表. 而获得到的聊天 ...
- Flask中无法在其他函数中查询Sqlachemy的解决办法
报错信息部分截取: File "D:\python 3.5\lib\site-packages\flask_sqlalchemy\__init__.py", line 912, i ...
- SQLAlchemy中的自引用
SQLALCHEMY采用adjacency list pattern来表示类的自引用. 例如,对于类Node自引用: class Node(Base): __tablename__='node' id ...
- 吴恩达课后作业学习2-week1-3梯度校验
参考:https://blog.csdn.net/u013733326/article/details/79847918 希望大家直接到上面的网址去查看代码,下面是本人的笔记 5.梯度校验 在我们执行 ...