vue动态轮番图和走马灯

//<m-lunf :tongxin="lunf1"></m-lunf>
//lunf1:{"timeSpace":2,"url":"","num":1,"title":"TransOcean "} ,
Vue.component('m-lunf', {
      template: 
'<div id="lf" style="position:relative;width:100%;    height:300px;   margin:0 auto;  overflow:hidden; " >'+
'  <div  style="display: flex;height:100%  " >'+
'   <div id="" style="color:#ffa900; text-align :center ;font-size :3.4em;position:absolute;width:100%; ">{{tongxin.title}} </div>'+
'   <div v-for="index of tongxin.num" :key="index" style="width:100%; "   @mouseover="btnOpen" @mouseout="btnHide" >'+
'    <img :src="list[index].ImagePath" width="100%" height="100%">'+
'  </div>'+
' </div>'+
'</div>',
      props: {
       tongxin:""
     },
      watch: {
        },
      created(){
        //this.getren()
      },
	mounted: function() {this.timeSpace=this.tongxin.timeSpace
				this.$nextTick(function () {
				this.getchang()
				this.lun()})

			},

      data() {
        return {timeSpace:1,
					list: [
						{ ImagePath: 'http://60.2.62.150:100/SYSA/edit/upimages/n.jpg' },
						
						{ ImagePath: 'https://cache.yisu.com/www/images/ddos_4.png' }, {ImagePath: 'http://60.2.62.150:100/SYSA/edit/upimages/n.jpg' },
					
						{ ImagePath: 'https://cache.yisu.com/www/images/ddos_4.png' }
					],
					pressList: [{ name: '1', isShow: false }, { name: '2', isShow: false }, { name: '3', isShow: false }, { name: '4', isShow: false }, { name: '5', isShow: false }],
					numList: ['p0', 'p1', 'p2', 'p3', 'p4'],
					imgIndex: 0,
					timer: null,jz: false,
					btnShow: false
				}
      },
      methods: {

lun: function(){
//this.imgMove()
this.slideAuto()
 
},
 getchang: function(){var  that=this

/*
var ul="Templates/js.asp?Sort=38"
	  fly.get(ul, {  })
  .then(function (response) {
//var bb1= JSON.parse(response.data.trim())
var bb1=new Function('return '+response.data.trim())();//字符串转对象

 that.init(bb1)
  })
*/
this.jz=true
},
//产品初始
init: function(hh){var gg=[],bb={}
hh.forEach(function(s0){

bb.ImagePath=s0.ImagePath

gg.push({"ImagePath":s0.ImagePath})

});
 
this.list=gg
this.jz=true

 },    //setInterval  —— 会不停的调用函数setTimeout —— 只会执行函数一次
  //向右移动
   rightMove:function(){
 this.list.push(this.list[0]);
 this.list.shift();
   //console.log(this.pic);
   },

  slideAuto:function () {
    var _this = this;
    _this.timer = setTimeout(function () {
  //console.log( _this.jz);
     if(_this.jz){
      _this.rightMove();
      _this.slideAuto();
     }
    }, _this.timeSpace * 1000);
   },
	   /*
imgMove: function() {  var  that=this
this.jz=true
	this.imgTimer = setInterval(function (){
if (that.jz)
{that.imgIndex=that.imgIndex+1
if(that.imgIndex >that.list.length-1)	that.imgIndex = 0

that.pic=that.list[that.imgIndex].ImagePath

}
					}, 3000)
				},*/
btnOpen() {
					this.btnShow = true;
					clearInterval(this.timer)
				},
btnHide() {
					this.btnShow = false;
					this.slideAuto()
				},


      }
    })

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值