简体   繁体   English

Laravel + Vue Js:如何从Axios请求中获取响应时隐藏Bootstraps 4模式

[英]Laravel + Vue Js : How can i hide a bootstraps 4 modal on getting response from Axios request

I am using Laravel 5 with VueJs. 我在VueJs中使用Laravel 5。 I have a simple bootstrap4 modal having 3 input fields. 我有一个具有3个输入字段的简单bootstrap4模态。 On click submit data is sent to the database using AXIOS post request. 单击时,使用AXIOS发布请求将提交数据发送到数据库。

Now I want when I get a response (success) that bootstrap modal should hide. 现在,我想在收到响应(成功)时应该隐藏引导程序模式。 How can I achieve this? 我该如何实现?

code : 代码:

<script>
    export default{
      data(){
        return{
          list:{
          name:'',
          email:'',
          phone:''
        }
      }

      },
      methods:{
        save(){
          axios.post('/phonebook',this.$data.list).then((response)=>console.log(response))
  .catch((error)=>console.log(error))
        }

      }

    }
</script>

You can use like this: 您可以这样使用:

methods: {
  // ...
  if(response.status===200) this.closeModal();
  // ...
  closeModal() {
    $('#modal').modal('hide');
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Vue.js - 如何确定 axios 请求是否没有响应数据 - Vue.js - How to determine if an axios request has no response data 我如何在 Vue.js 中获得 axios 响应(v-on:click)(异步/尝试,捕获)? - How can I in Vue.js get axios response ( v-on:click ) (async / try,catch)? 如何从 vue.js Z38C3787939C7B0B6C79D73FCE3D28 获取 Laravel 中的 JSON? - How to get JSON in Laravel from vue.js axios POST? Laravel,Vue.js | 通过axios请求下载空白pdf - Laravel, Vue.js | blank pdf getting downloaded via axios request 我无法从 axios 请求返回响应 - I can't return the response from axios request 在 vue.js 中使用 axios 打印来自 http GET 请求的响应? - Print response from http GET request using axios in vue.js? Laravel Vue JS Mixins没有得到功能响应 - Laravel vue js mixins not getting function response 如何使用 async/await 编写 a.then function,以便我可以捕获来自 axios 的响应(在单独的文件和方法中,在 vue 中) - How can I write a .then function with async/await, so that I can catch the response from axios (in seperate files and methods, in vue) 我在 Node.js API 上使用 Axios 没有收到 GET 请求的响应 - I'm getting no response of GET request with Axios on my Node.js API 根据axios GET请求的响应填充Vue数据 - Populating Vue data based on response from axios GET request
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM