URLSearchParams和axios的post请求(防忘记)

 


import axios from 'axios'

Vue.prototype.axios = axios

mounted () {
  let params = new URLSearchParams()
  params.append('id', this.$route.params.id)
  params.append('cid', this.$route.params.cid)
  this.loading = true
  this.axios.post(this.host + 'Api/Pinyin/detail', params).then(res => {
    this.loading = false
    if (res.data.status) {
      this.all = res.data.info
      this.all.map((v, index) => {
        if (v.id === this.$route.params.id) {
          this.thumb = v.thumb
          this.index = index
          this.currentMp3 = v.mp3
          this.gif = v.gif
        }
      })
    }
  }).catch(function (res) {
    this.loading = false
  })
},

 

  

posted on 2017-12-13 16:58  Chen_s  阅读(765)  评论(0编辑  收藏  举报

导航