apicloud引用vue.js。
在methods中写以下:
initSwiper() {
// console.log(1231231)
var that = this
api.ajax({
url: 'http://10.50.128.156:8855/contentmanage/gethotplanhome',
method: 'post',
timeout: 5,
// dataType: 'json',
// returnAll: true,
}, function(ret, err) {
Vue.nextTick(function() {
var swiper = new Swiper('.swiper-container', {
slidesPerView: 'auto',
centeredSlides: true,
spaceBetween: 30,
loop: true,
pagination: {
el: '.swiper-pagination',
clickable: true,
},
});
});
// console.log(JSON.stringify(ret.data))
that.lunbo = ret.data;
// console.log(JSON.stringify(that.lunbo))
})
},
-----------------------------------------------------------------------------------------------、
在vue生命周期的created中ajax请求
在mounted挂载,
mounted() {
this.initSwiper();
}