1***@qq.com
1***@qq.com
  • 发布:2022-01-10 23:17
  • 更新:2022-01-11 17:35
  • 阅读:471

兄弟async无法使用啊,如下报错

分类:uni-app

代码:

onLoad () {

             this.getSwiperList()  
     },  
    methods: {  
         // 3. 获取轮播图数据的方法  
        async getSwiperList() {  
              // 3.1 发起请求  
              const { data: res } = await uni.$http.get('/api/public/v1/home/swiperdata')  
              // 3.2 请求失败  
              if (res.meta.status !== 200) {  
                return uni.showToast({  
                  title: '数据请求失败!',  
                  duration: 1500,  
                  icon: 'none',  
                })  
              }  
              // 3.3 请求成功,为 data 中的数据赋值  
              this.swiperList = res.message  
            },  
    },  

报错:

Error in onLoad hook: "TypeError: _regenerator.default.mark is not a function"

2022-01-10 23:17 负责人:无 分享
已邀请:
星星不怕黑

星星不怕黑

const { data: res } = await uni.$http.get('/api/public/v1/home/swiperdata')

这个冒号是什么写法?没见过,是不是这里问题

  • 1***@qq.com (作者)

    不是,已经自己解决了,写错了基准地址参数,导致请求失败。这是es6的写法

    2022-01-12 11:41

该问题目前已经被锁定, 无法添加新回复