Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支付宝小程序在启动页中无法请求云函数,点击事件可以获取 #4696

Closed
BUPTlhuanyu opened this issue Jan 19, 2024 · 3 comments
Labels
mp-alipay 支付宝小程序 uniCloud

Comments

@BUPTlhuanyu
Copy link

BUPTlhuanyu commented Jan 19, 2024

问题描述
支付宝小程序在启动页无法请求云函数

复现步骤

<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
  • 设备信息

补充信息
[可选]
[根据你的分析,出现这个问题的原因可能在哪里?]

@BUPTlhuanyu BUPTlhuanyu changed the title 支付宝小程序在启动页组件的mounted生命周期中无法获取 refs 支付宝小程序在启动页中无法请求云函数,点击事件可以获取 Jan 19, 2024
@Otto-J Otto-J added mp-alipay 支付宝小程序 uniCloud labels Apr 29, 2024
@qq370725567
Copy link

  1. 本地运行时,确保支付宝云的IDE那设置了忽略域名校验,因为会有127.0.0.1的请求无法通过域名校验

@qq370725567
Copy link

  1. 目前测试结果是onLoad内可以执行云函数

@Otto-J
Copy link
Member

Otto-J commented Aug 1, 2024

@Otto-J Otto-J closed this as completed Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mp-alipay 支付宝小程序 uniCloud
Projects
None yet
Development

No branches or pull requests

3 participants