使用mpvue開發小程序,在A頁面onLoad時請求接口并賦值渲染,代碼如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
methods: { ? ? getReadList() { ? ? ? ? this.bookList = []; ? ? ? ? request(`book/all`, "GET").then(res => { ? ? ? ? ? ? if (res.status == 1000) { ? ? ? ? ? ? ? ? res.content.forEach(item => { ? ? ? ? ? ? ? ? ? ? this.bookList.push(item) ? ? ? ? ? ? ? ? }); ? ? ? ? ? ? } ? ? ? ? }); ? ? } }, onLoad() { ? ? this.getReadList(); } |
但是在app.json中配置了plugins后,A頁面渲染不出bookList的數據。愛掏網 - it200.com
在請求回調中不通過forEach循環,直接用this.bookList = res.content能正常渲染。愛掏網 - it200.com
很困惑,這到底是什么原因呢?
? ?
聲明:所有內容來自互聯網搜索結果,不保證100%準確性,僅供參考。如若本站內容侵犯了原著者的合法權益,可聯系我們進行處理。