vue后端数据接收

在method中定义一个getList()方法

getList(){
			uni.request({
						url:"url"//这里放后端地址,
						success: res=>{
							this.goodList = res.data
							console.log(this.goodList)
						},
						fail: err=>{
							uni.showToast({
								title:"请求失败...",
								icon:"none"
							})
							console.log(err)
						}
					})
		}

随后在data定义goodList存储接收的内容

data(){
    return{
            goodList:[],
        }
}

这里需要看项目的需要使用,使用onLoad()在项目加载的时候把method中的getList()运行一次

onLoad(){
    this.getList();
}

猜你喜欢

转载自blog.csdn.net/qq231062/article/details/129475284