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 父组件传值的更多相关文章

  1. vue中的父组件传值给子组件

    以上父组件以及父组件里面的代码 下面是子组件以及里面的代码

  2. 【vue开发】 父组件传值给子组件时 ,watch props 监听不到解决方案

    解决方案: watch:{ data:{ immediate:true, handler:function(){ } }} 示例:  

  3. vue 父组件给子组件传值,子组件给父组件传值

    父组件如何给子组件传值 使用props 举个例子: 子组件:fromTest.vue,父组件 app.vue fromTest.vue <template> <h2>{{tit ...

  4. Vue 组件&组件之间的通信 之 子组件向父组件传值

    子组件向父组件传值:子组件通过$.emit()方法以事件形式向父组件发送消息传值: 使用步骤: 定义组件:现有自定义组件com-a.com-b,com-a是com-b的父组件: 准备获取数据:父组件c ...

  5. vue+elementUI项目,父组件向子组件传值,子组件向父组件传值,父子组件互相传值。

    vue+elementUI项目,父组件向子组件传值,子组件向父组件传值,父子组件互相传值. vue 父组件与子组件相互通信 一.父组件给子组件传值 props 实现父组件向子组件传值. 1父组件里: ...

  6. 【转】Vue组件一-父组件传值给子组件

    Vue组件一-父组件传值给子组件 开始 Vue组件是学习Vue框架最比较难的部分,而这部分难点我认为可以分为三个部分学习,即 组件的传值 - 父组件向子组件中传值 事件回馈 - 子组件向父组件发送消息 ...

  7. vue 组件-父组件传值给子组件

    父组件通过属性,传值给子组件,子组件通过,props数组里的名称来接受父组件传过来的值. HTML部分: <div id="app"> <tmp1 :parent ...

  8. vue父组件调用子组件方法、父组件向子组件传值、子组件向父组件传值

      一.父组件调用子组件方法 父组件代码  parent.vue <template> <div> <button @click="parentFun" ...

  9. vue 和react中子组件分别如何向父组件传值

    vue子组件和父组件双向传值: 子: Vue.component("childComponent",{ template:`<div><p @click='pos ...

随机推荐

  1. ObjectARX开发VC版本对照表R14~AutoCAD2020

  2. idea创建maven web项目需要注意的一些细节

    在idea中构建maven java web项目,从new project到选择maven骨架到最后finish完成,整个流程完成后,项目基本结构已经出来,但是距一个可以正常开发运行的web项目还有一 ...

  3. hashmap源码解析,JDK1.8和1.7的区别

    背景:hashmap面试基础必考内容,需要深入了解,并学习其中的相关原理.此处还要明白1.7和1.8不通版本的优化点. Java 8系列之重新认识HashMap Java 8系列之重新认识HashMa ...

  4. vue通过ajax加载json数据

    HTML <ul id="Hanapp"> <li class="styVue" v-for="item in actList&qu ...

  5. Fiddler如何切换hosts以及切换hosts的另一个神器SwithcHosts

  6. python 之 Django框架(服务器程序和应用程序、基础必备三件套及相关配置)

    第十二章 Django框架 12.1 服务器程序和应用程序 服务器程序负责对socket服务器进行封装,并在请求到来时,对请求的各种数据进行整理.应用程序则负责具体的逻辑处理.为了方便应用程序的开发, ...

  7. R学习笔记2 因子

    特殊值: 缺失值 NA(Not Avaiable),是不可用的缩写: NaN为“不是一个数”,意味着计算没有数学意义: NULL值,空值,表示一个空的变量,不会占用任何空间,通过is.null(x)来 ...

  8. Springboot 结合百度IORC实现自定义模板图片识别

    前言: 首先呢,最近再公司的项目当中遇到这样的一个问题,就是需要识别图片,提取图片当中的关键语句,而且识别的语句当然是人家手写体识别,翻来覆去一想,最终还是决定使用百度的OCR帮助我解决这一项需求 话 ...

  9. oracle数据库 部分函数的用法

    select * from tab; //获取当前用户的数据库的所有表名 select sys_guid(),UserName from TESTLIKUI; //获取guid select sys_ ...

  10. R_基本统计分析_06

    summary()提供基础的统计信息 sapply(x,FUN,options)可以指定统计函数 fivenum()可以返回图基五数 Hmisc 中的describe(data)返回变量,观测的变量, ...