小编Wil*_*ree的帖子

如何使用Axios Async Await使用Promise.all

我在Nuxt.js中有此Axios Async Await代码,但不确定如何以及在何处放置Promise.all此代码。我试图向getThemes()and 承诺getData()。有人可以帮我提供Promise.all代码吗?

而且我必须把Promise.allmounted()

mounted() {
    this.getData(this.$route.params.id);
    this.getThemes();
  },

  methods: {
    async getThemes() {
      this.loading = true;
      await axios.get(`${process.env.API_URL}/v1/communication/email-themes`, {}).then((response) => {
        this.theme = response.data.data;
        this.selected = this.theme.filter(t => this.themeId === t.id)[0].id;
        this.loading = false;
      }).catch((error) => {
        this.loading = false;
        this.errormsg = error.response.data.message;
      });
    },

    async getData(id) {
      this.loading = true;
      await axios
        .get(`${process.env.API_URL}/v1/communication/email-templates/${id}`)
        .then(({
          data
        }) => {
          this.templateName = data.data.name;
          this.templateCode = data.data.content;
          this.themeId …
Run Code Online (Sandbox Code Playgroud)

javascript promise vue.js nuxt.js

0
推荐指数
1
解决办法
4603
查看次数

VueJS 组件上的 v-if

需要一个简单的快速修复,当 .env 中的 NODE_ENV 不是“生产”时,我想在我的 VueJS 页脚上显示一个“DEVELOPMENT”标签。请帮忙。

<template>
    <footer class="app-footer font-xs" v-if="process.env.NODE_ENV !== 'production'">
        <span>© 2018 <b>PT Test</b>. All Rights Reserved.</span>
        <span class="ml-auto">DEVELOPMENT</span>
    </footer>
    <footer v-else class="app-footer font-xs">
        <span>© 2018 <b>PT Test</b>. All Rights Reserved.</span>
    </footer>
</template>
Run Code Online (Sandbox Code Playgroud)

我的 .env 文件

NODE_ENV=local
TZ=Asia/Jakarta
Run Code Online (Sandbox Code Playgroud)

vue.js vue-component vuejs2 nuxt.js

0
推荐指数
1
解决办法
1502
查看次数

标签 统计

nuxt.js ×2

vue.js ×2

javascript ×1

promise ×1

vue-component ×1

vuejs2 ×1