使用await/async进行数据请求

74 阅读1分钟

接口请求实例

使用await/async进行数据请求

  async mounted() {
    await this.getData()
  },
  methods: {
    async getData() {
      try {
        const res = await trend();
        this.list = res.data;
      } catch (err) {
        console.error(err);
      }
    },
  },