next
只能調用一次,這邊可以用
解決,等待兩個異步操作都返回結果後再 next
:
beforeRouteEnter (to, from, next) {
// 會等到數組內的 Promise 都 resolve 後才會繼續跑(then)
([
main._base({
methodName: 'QueryProductInfo', productId: }), main._base({ methodName: 'QueryProductReview', type: '0', index: '0', count: '2', productId: }) ]) .then( result => next( vm => { // 執行結果會按照上面順序放在 result 數組內,所以 result[0],代表第一個函數的 resolve 結果 = result[0]. = result[0]. = result[1].data })) }
转载于:/cainiao-vcu/p/