zoukankan      html  css  js  c++  java
  • vue-resource 知识点

    this.$http.post('xxx', params, {emulateJSON: false, headers: {'Content-Type': 'application/json;charset=utf-8'}})
      .then(response => {
        console.log(response)
      })
      .catch(error => {
        console.log(error)
      })
    
    • vue-resource 使用示例:
            this.$http
                // 可以设置过期时间为100ms,来模拟超时
                // .get(this.url, { timeout: 100 })
                .get(this.url)
                .then((response) => {
                    console.log(response)
                    this.status = response.status
                    this.statusText = response.statusText
                })
                // 网络错误、url地址错误、请求超时,能被catch捕获
                .catch((error) => {
                    console.log(error)
                    this.status = error.status
                    this.statusText = error.statusText
                })
    
    • If your web server can't handle requests encoded as application/json, you can enable the emulateJSON option. This will send the request as application/x-www-form-urlencoded MIME type, as if from an normal HTML form.
    Vue.http.options.emulateJSON = true;
    
  • 相关阅读:
    PHP PDO
    常用JavaScript字符串方法简述
    命名
    jquery远程班备忘
    html历史
    CSS3的翻转效果
    正则
    排序算法
    firebug的调试,console
    跨域
  • 原文地址:https://www.cnblogs.com/cag2050/p/7561982.html
Copyright © 2011-2022 走看看