Vue.js disable component during ajax request

后端 未结 3 1480
执念已碎
执念已碎 2021-01-13 03:52

I\'m looking for a simple solution for the following problem:

I have a Vue component button with which I can make an ajax request. I would like to disable this butto

3条回答
  •  独厮守ぢ
    2021-01-13 04:12

    State.js:

    state: {
      pendingRequest: false
    },
    actions: {
      fetchRequest: async function(context) {
        context.state.pendingRequest = true
        let req = await fetch(url)
        let data = await req.json()
        context.state.pendingRequest = false
      }
    }
    

    Component.vue:

    
    

提交回复
热议问题