これに問題があります。ajaxのtotalUserPostsが返された後にゼロが返されます。すべてのVuejsのデータを変更
new Vue({
el: "#app",
data: {
totalUserPosts:0,
},
methods:{
getPostsAjax() {
$.ajax({
url:url,
type: 'get',
cache: false,
dataType: "json",
data:{
limit: this.limit,
id: this.vue_profile_id
}
}).done((data) => {
this.userPosts = data.posts;
this.totalUserPosts = data.total
}.bind(this))
},
getUserPosts() {
this.getPostsAjax()
$(window).scroll(() => {
if($(window).scrollTop() + $(window).height() > $(document).height() - 150) {
console.log(this.totalUserPosts)
}
})
}
})
は、私はあなたのAjaxの機能が戻る前にスクロールを呼んでいる
console.log(this.totalUserPosts);それが割り当てられた後のdone関数の中で出力が何であるか教えてください。 – TehSphinX
totalUserPostsの戻り値= 11 – kamyab
これは戻りません。 – kamyab