uni-app
uni-app copied to clipboard
支付宝小程序在启动页中无法请求云函数,点击事件可以获取
问题描述 支付宝小程序在启动页无法请求云函数
复现步骤
<template>
<view class="home">
<view ref="test123" @click="test">点击调试</view>
</view>
</template>
<script>
import {
mapState,
mapMutations
} from 'vuex';
export default {
data() {
return {}
},
computed: {
...mapState([
'movieList',
])
},
onLoad() {
setTimeout(() => {
this.test();
}, 10000)
},
watch: {},
methods: {
...mapMutations(['setSelectedMovie', 'setMovieList']),
test(e) {
uniCloud.callFunction({
name: 'movie-list',
data: {}
}).then(res => {
console.log('list res', res)
//this.movieList = res.result.data.data
this.setMovieList(res.result.data.data)
}).catch(err => {
console.log('err', err)
uni.showModal({
content: err.errMsg,
showCancel: false
});
})
},
}
}
</script>
<style lang="scss">
</style>
预期结果 onLoad 里得请求数据总是失败,点击得时候可以获取数据。
实际结果 onLoad 可以获取
系统信息:
- 发行平台: 支付宝小程序
- 操作系统 Android
- HBuilderX版本 3.98
- uni-app版本 3.98
- 设备信息
补充信息 [可选] [根据你的分析,出现这个问题的原因可能在哪里?]