console
import api from '../api/api';
import BScroll from 'better-scroll';
export default{
name:'demo',
data(){
return{
pros:[
],
page:1,
homeUrl:global.home_url,
}
},
created(){
this.GetIndexLove(this.page);
},
methods:{
GetIndexLove: function(page){
api.ajax('GetIndexLove',{device: "3", channel_id:1, pageIndex:page}).then(res => {
if(res.data.length == 0){
this.more = '我也是有底线的';
}
this.pros = this.pros.concat(res.data);
this.$nextTick(() => {
if (!this.scroll) {
this.scroll = new BScroll(this.$refs.wrapper, {
click:true,
bounce:false,
})
this.scroll.on('touchEnd', (pos) => {
if (pos.y <= (this.scroll.maxScrollY + 50)) {
this.GetIndexLove(++this.page);
}
this.scroll.refresh()
})
} else {
this.scroll.refresh()
}
})
}).catch(error => {
console.log(error)
});
},
alert(){
console.log(123)
}
}
}
<template>
<div>
<section id="scroll-wrapper" class="wrapper" ref="wrapper">
<div id="scroll-container" class="content">
<ul class="production-list-container">
<li v-for="(pro,index) in pros">
<router-link :to="{path:'detail',query:{pid:pro.id}}">
<h5 class="text-ellipsis-2" @click.stop.prevent="alert">{{index}}</h5>
</router-link>
</li>
</ul>
</div>
</section>
</div>
</template>
ul{padding: 0; margin:0;}
li{display: inline-block;
vertical-align: top;
width: 3.7rem;
height: 5.2rem;
margin: 0 0 0.1rem 0;
background-color: #f4f4f4;
}
li a{
width: 3.7rem;
height: 5.2rem;
display: inline-block;
}
li:nth-child(2n){
background-color: #ccc;
}