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. SOC中的DMIPS_GFLOPS_GMACS的含义

    l  DMIPS全称叫Dhrystone MIPS 这项测试是用来计算同一秒内系统的处理能力,它的单位以百万来计算,也就是(MIPS) 上面的意思也就是,这个处理器测整数计算能力为(200*100万) ...

  2. 博客迁移到github了

    博客迁移到github了,这边基本不更新, 主要是没有找到快捷的同步方法,手动同步太麻烦了,如果你有快速把github博客同步到博客园的方法请一定告诉我

  3. Spring Boot拦截器实现并和swagger集成后使用拦截器的配置问题

    1. 定义拦截器 LoginInterceptor LoginInterceptor.java是整个登录认证模块中的核心类之一,它实现了HandlerInterceptor类,由它来拦截并过滤到来的每 ...

  4. mysql 按照计算值排序

    SELECT title,browse_num/exposure_num as click_rate FROM `tf_news` ORDER BY browse_num/exposure_num d ...

  5. 史上最详细bitbucket入门手册,手把手操作指南

    老大要我去调研一下有什么好用的免费软件版本管理工具,有利于小团队开发的.我第一个想到的就是git,经常在git下东西,听说它的代码仓库好用,于是就注册了一个github的账号,创建仓库的时候才发现只能 ...

  6. linux命令及相关配置

    hostname # 查看 hostname vim /etc/hostname # 修改hostname,重启后生效 vim /etc/resolv.conf 写入 nameserver 192.1 ...

  7. Prometheus入门到放弃(7)之redis_exporter部署

    redis监控,prometheus需要使用redis_exporter客户端. 这里我们采用docker方式部署,既可以部署在redis所在服务器,也可以部署在其他机器: docker镜像地址:ht ...

  8. Kafka Streams | 流,实时处理和功能

    1.目标 在我们之前的Kafka教程中,我们讨论了Kafka中的ZooKeeper.今天,在这个Kafka Streams教程中,我们将学习Kafka中Streams的实际含义.此外,我们将看到Kaf ...

  9. Java 8 Optional 的用法

    认识Optional   Optionals是用于防止 NullPointerException 的漂亮工具.让我们快速了解一下Optionals的工作原理. Optional 是一个简单的容器,其值 ...

  10. 基于Snappy实现数据压缩和解压

    Snappy是谷歌开源的一个用来压缩和解压的开发包.相较其他压缩算法速率有明显的优势,官方文档显示在64位 i7处理器上,每秒可达200~500MB的压缩速度,不禁感叹大厂的算法就是厉害. 开源项目地 ...