vue 关于props 父组件传值
swiper.vue 子组件
info.vue 父组件
swiper.vue
<template>
<div class="swiper-wrap" @mouseover="autoPlayStop" @mouseout="autoPlayStart(0)">
<p>
<img :src="sildeArr[nowIndex]" >
</p>
<p class="sli-page">
<span @click="goto(prev)"><</span>
<span v-for="(item,index) in sildeArr" :style="{'color': nowIndex == index ? active : unActive}" @click="goto(index)">{{index+1}}</span>
<span @click="goto(next)">></span>
</p>
</div>
</template>
<script> export default({
name:'swiper',
props:{
unActive:{//索引默认颜色
type:String,
default: '#f5f5f5',
},
active:{//索引选中颜色
default: '#ccc',
},
autoPlaytime:{
type:Number,
default:3000
} },
data(){
return {
nowIndex:0,
autoPlaytype:true
}
},
computed:{
prev(){
if(this.nowIndex==0){
return this.sildeArr.length-1
}else{
return this.nowIndex-1
}
// nowIndex--;
},
next(){
if(this.nowIndex==this.sildeArr.length-1){
return 0
}else{
return this.nowIndex+1
}
}
},
methods:{
goto(index){
this.nowIndex=index
},
autoPlayStop(){
let _this=this;
clearInterval(_this.autoPlaytype)
},
autoPlayStart(i){
let _this=this;
_this.autoPlaytype=setInterval(()=>{
_this.goto(_this.next)
},_this.autoPlaytime) }
},
mounted(){
this.autoPlayStart();
}
})
</script> info.vue
<template>
<div>
<swiper :sildeArr="img" :autoPlaytime="time" unActive="#888" active="#fff" ></swiper>
</div>
</template>
<script type="text/javascript">
import swiper from './swiper'
import dataImg from '../data/aboutme';
export default({
name:'header',
data(){
return{
img:[],
time:2000
}
},
created (){
this.$router.push('/heade/info');
this.$router.push('info');
this.$http.get('http://img.cn').then((data)=>{
let dataImg=JSON.parse(data.bodyText);
this.img=dataImg.img
});
},
components: {swiper}
})
</script>
vue 关于props 父组件传值的更多相关文章
- vue中的父组件传值给子组件
以上父组件以及父组件里面的代码 下面是子组件以及里面的代码
- 【vue开发】 父组件传值给子组件时 ,watch props 监听不到解决方案
解决方案: watch:{ data:{ immediate:true, handler:function(){ } }} 示例:
- vue 父组件给子组件传值,子组件给父组件传值
父组件如何给子组件传值 使用props 举个例子: 子组件:fromTest.vue,父组件 app.vue fromTest.vue <template> <h2>{{tit ...
- Vue 组件&组件之间的通信 之 子组件向父组件传值
子组件向父组件传值:子组件通过$.emit()方法以事件形式向父组件发送消息传值: 使用步骤: 定义组件:现有自定义组件com-a.com-b,com-a是com-b的父组件: 准备获取数据:父组件c ...
- vue+elementUI项目,父组件向子组件传值,子组件向父组件传值,父子组件互相传值。
vue+elementUI项目,父组件向子组件传值,子组件向父组件传值,父子组件互相传值. vue 父组件与子组件相互通信 一.父组件给子组件传值 props 实现父组件向子组件传值. 1父组件里: ...
- 【转】Vue组件一-父组件传值给子组件
Vue组件一-父组件传值给子组件 开始 Vue组件是学习Vue框架最比较难的部分,而这部分难点我认为可以分为三个部分学习,即 组件的传值 - 父组件向子组件中传值 事件回馈 - 子组件向父组件发送消息 ...
- vue 组件-父组件传值给子组件
父组件通过属性,传值给子组件,子组件通过,props数组里的名称来接受父组件传过来的值. HTML部分: <div id="app"> <tmp1 :parent ...
- vue父组件调用子组件方法、父组件向子组件传值、子组件向父组件传值
一.父组件调用子组件方法 父组件代码 parent.vue <template> <div> <button @click="parentFun" ...
- vue 和react中子组件分别如何向父组件传值
vue子组件和父组件双向传值: 子: Vue.component("childComponent",{ template:`<div><p @click='pos ...
随机推荐
- [LeetCode] 543. Diameter of Binary Tree 二叉树的直径
Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a b ...
- 错误:net::ERR_BLOCKED_BY_CLIENT
提示net::ERR_BLOCKED_BY_CLIENT错误 解决办法: 当我们查看浏览器第三方插件的时候,就会看到插件中存在“广告过滤插件”,其实,报错的原因就是第三方广告过滤插件在捣鬼, 当你关闭 ...
- Kubernetes 健康状态检查(九)
强大的自愈能力是 Kubernetes 这类容器编排引擎的一个重要特性.自愈的默认实现方式是自动重启发生故障的容器.除此之外,用户还可以利用 Liveness 和 Readiness 探测机制设置更精 ...
- SpringBoot系列教程web篇之Beetl环境搭建
前面两篇分别介绍了目前流行的模板引擎Freemaker和Thymeleaf构建web应用的方式,接下来我们看一下号称性能最好的国产模板引擎Beetl,如何搭建web环境 本文主要来自官方文档,如有疑问 ...
- LeetCode 23. 合并K个排序链表(Merge Two Sorted Lists)
23. 合并K个排序链表 23. Merge k Sorted Lists 题目描述 合并 k 个排序链表,返回合并后的排序链表.请分析和描述算法的复杂度. LeetCode23. Merge k S ...
- 【转帖】你知道X86构架,你知道SH构架吗?
你知道X86构架,你知道SH构架吗? https://www.eefocus.com/mcu-dsp/363100 前面我们讲到了 8 位处理器,32 位处理器,以及 X86 构架,那么除了这些还 ...
- 38 多线程(十)——volatile 数据同步
在多线程并发的情况下,同一个变量被多个线程调用,那修改的数据就不会每分每秒保持一致.例如,对于某个变量a,线程1对它进行一套操作,线程2又对它进行另一套操作,但如果cpu太忙了,太忙了,假设cpu都用 ...
- PB 奇葩BUG
1. 在数据窗口的Edit 中选则CHeckBox 后,必须给默认值,否则会导致数据保存不了,也无提示. 2.当使用数据窗口的 setfile()函数时 如果 条件中有两个LIKE 则会报错,一个LI ...
- [LOJ #2833]「JOISC 2018 Day 1」帐篷
题目大意:有一个$n\times m$的网格图,若一个人的同一行或同一列有人,他就必须面向那个人,若都无人,就可以任意一个方向.若一个人无法确定方向,则方案不合法,问不同的方案数.$n,m\leqsl ...
- Install Gnome desktop
Install Gnome desktop http://www.dinggd.com/index.php/freebsd-8-0-rc1-gnome%E6%A1%8C%E9%9D%A2%E5%AE% ...