vue实现⽆限轮播_vue中轮播图的实现Title
上⼀张
下⼀张
let vm = new Vue({ // 声明变量 实例化⼀个对象vm(指的是vue的实例)
el:"#app", //绑定根元素
data(){
return{
images:[ //数据
{id:1,imgSrc:"img/1.jpg"},
{id:2,imgSrc:"img/2.jpg"},
{id:3,imgSrc:"img/3.jpg"},
/
/ {id:4,imgSrc:"img/4.jpg"},
],
currentIndex:0 //⼀开始设置为 0
}
},
methods:{// 对象内容是js函数
nextHandler(e){
console.log(e);
this.currentIndex++;
//更改图⽚地址
if (this.currentIndex == 3){ //js的if判断语句
this.currentIndex = 0;
}
},
prevHandler(e) {
console.log(e);
this.currentIndex--;
//更改图⽚地址
if (this.currentIndex == 0) { //js的if判断语句
this.currentIndex = 3;
}
},
imgHandler(e){ //每⼀个事件都有⼀个event对象, 冒泡阻⽌默认事件学的
console.log(e.target);//当前⽬标对象
console.log(this); //实例化⾥⾯的对象this 指的都是当前实例化对象
}
},
//create() 组件创建完成, 组件创建完成⽴马往后台发ajax
// ajax vue的钩⼦函数
// created(){
// // console.log(this); //就是当前的vm
// setInterval(function(){
// console.log(this);//this是window对象 但是想把this的指向改成vm 所以把匿名函数改成箭头函数
/
/ },1000)
// }
js实现轮播图最简代码
created(){
// this的指向问题 ************* 能⽤箭头函数不⽤匿名函数
//匿名函数改成箭头函数 this代指vue
setInterval( ()=>{
console.log(this);//this是 vue 对象
},1000)//⾃动循环播放图⽚ 1秒播放⼀次
}
})
Bootstrap中轮播图
Bootstrap中轮播图插件叫作Carousel,为了清晰的表明每个标签在这⾥是什么意思,我把解释写在了下⾯的代码中.
Linux c使⽤gumbo库解析页⾯表单信息(⼆)
⼀.如何在程序当中使⽤gumbo? 要想在代码中使⽤gumbo,仅仅包含gumbo头⽂件是不够的,必须在编译程序的时候加上-lgumbo选项,编译程序才会链接到gumbo库上⾯. 这是我编译gumbo ...
Error configuring application listener of class org.
解决⽅案 1:  1. 打开⼯程属性对话框,到Deployment Assembly页⾯,点击Add  2. 选择Jave Build Path Entries 3. 把程序⽤于的Library加 ...
CF401D Roman and Numbers
题意: 将n(n<=10^18)的各位数字重新排列(不允许有前导零) 求 可以构造⼏个mod m等于0的数字 分析: 状态压缩 状态: 设f[s][k]表⽰对于选择数字组合的s来说,%m等于k的 ...
ArrayList初步
使⽤ArrayList,需添加引⽤:using System.Collections: 第⼀个例⼦: ArrayList list = new ArrayList(); list.Add(" ...