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] 284. Peeking Iterator 瞥一眼迭代器
Given an Iterator class interface with methods: next() and hasNext(), design and implement a Peeking ...
- SQL server触发器学习记录
作为C#程序员,我工作内容基本就是winform,wpf,asp.net.sql接触的比较少,今天突然来了一个ticket要我修改触发器脚本....只会select*的我顿感迷茫... 需求描述:as ...
- 【视频开发】关于FFMPEG中内存泄漏的问题之av_bitstream_filter_filter
How may I free pkt in an ffmpeg write frame method Rate this: See more: C++ ffmpeg Greetings I' ...
- 利用VBA来实现,输入日文之后,输出它的假名即读法
背景:当你输日文汉字的额时候,输出它的读音. 如下图所示 实现的代码如下 Option Explicit ' Replace を まとめて おこなう Private Function ReplaceA ...
- Spring的日志管理
一.spring的日志依赖 Logging是spring中唯一强制的外部依赖,spring中默认使用的日志是commons-logging,简称JCL,这里说的强制性,是因为在spring-core这 ...
- Lambda的延迟执行
在兼顾面向对象特性的基础上,Java语言通过Lambda表达式与方法引用等,为开发者打开了函数式编程的大门. 下面我们做一个初探. Lambda的延迟执行 有些场景的代码执行后,结果不一定会被使用,从 ...
- docker+k8s基础篇二
Docker+K8s基础篇(二) docker的资源控制 A:docker的资源限制 Kubernetes的基础篇 A:DevOps的介绍 B:Kubernetes的架构概述 C:Kubernetes ...
- PHP字符串替换
$pid = str_replace(',',',',$pid); $pid = str_replace(' ','',$pid); $pid = str_replace(array(',', ' ' ...
- 基于Snappy实现数据压缩和解压
Snappy是谷歌开源的一个用来压缩和解压的开发包.相较其他压缩算法速率有明显的优势,官方文档显示在64位 i7处理器上,每秒可达200~500MB的压缩速度,不禁感叹大厂的算法就是厉害. 开源项目地 ...
- Educational Codeforces Round 71
https://www.cnblogs.com/31415926535x/p/11460682.html 上午没课,做一套题,,练一下手感和思维,,教育场的71 ,,前两到没啥,,后面就做的磕磕巴巴的 ...