可以在请求拦截器中添加一个等待框,请求成功后再关闭等待框。具体实现代码如下:

// main.js
import Vue from 'vue'
import App from './App'
import uView from "uview-ui";
Vue.use(uView);

Vue.config.productionTip = false

// 添加请求拦截器
uni.addInterceptor('request', {
  invoke: function(args) {
    uni.showLoading({
      title: '加载中...'
    });
  }
});

// 添加响应拦截器
uni.addInterceptor('response', {
  invoke: function(res) {
    uni.hideLoading();
    return res;
  }
});

App.mpType = 'app'

const app = new Vue({
  ...App
})
app.$mount()

在请求拦截器中,我们调用了uni.showLoading()方法来显示一个等待框。在响应拦截器中,我们调用了uni.hideLoading()方法来关闭等待框。这样在每次请求时都会显示一个等待框,请求完成后等待框会自动关闭

JSONstringifyresdata 删除返回值中的一些字改写uniapp vue 程序 请求时弹出等待框

原文地址: https://www.cveoy.top/t/topic/crLW 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录