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 ...
随机推荐
- C++ 中operator用法:隐式类型转换
[转]C++ operator两种用法 C++,有时它的确是个耐玩的东东,就比如operator,它有两种用法,一种是operator overloading(操作符重载),一种是operator c ...
- 力扣算法题—050计算pow(x, n)
#include "000库函数.h" //使用折半算法 牛逼算法 class Solution { public: double myPow(double x, int n) { ...
- Announcing the Updated NGINX and NGINX Plus Plug‑In for New Relic (Version 2)
In March, 2013 we released the first version of the “nginx web server” plug‑in for New Relic monitor ...
- 【转】cookie如何共享到各个浏览器
可以考虑HTML5 localstorage, 点击查看原始尺寸 http://www.cnblogs.com/xiaowei0705/archive/2011/04/19/2021372.html也 ...
- 寒假特训——I - Fair
Some company is going to hold a fair in Byteland. There are nn towns in Byteland and mm two-way road ...
- windows通过node环境搭建安装npm,cnpm,vue-cli
1首先下载node,官网地址:https://nodejs.org/en/ 左边是稳定版,右边是最新版,安装过程一样,我选择的是稳定版. 按照步骤一步一步的安装就行,注意路径就可以了. 友情链接:ht ...
- 水题:P2799 国王的魔镜
思路:简单模拟即可.判断一下是不是回文,是回文看长度是不是偶数.是偶数的话,说明又可能是回文.依次这样处理.但是只要长度为奇数则一定是原来的长度直接输出即可. #include<iostream ...
- Python:Day40 html
URL包括三个部分:协议.域名.路径 htyper text markup language (html) 即超文本标记语言 前端一共包括三个内容:html.css.js html做为基础,让CSS ...
- 在开发框架中使用FTP辅助类上传或者下载文件,方便管理附件内容
在有些系统应用里面,我们需要对应用服务器.数据库服务器.文件服务器进行分开,文件路径等信息存储在数据库服务器里面,但文件内容则存储在文件服务器里面,通过使用FTP进行文件的上传下载,从而实现更加高效的 ...
- 使用Thrift让Python和C#可以相互调用
在聊如何使用Thrift让Python和C#可以互相调用之前,我们先来看看下面的话题. 一.什么是微服务.微服务的特征.诞生的背景.优势和不足 微服务:使用一套小服务来开发单个应用的方式,每个服务运行 ...