【问题标题】:Getting TypeError: t.replace is not a function Vue.js获取 TypeError:t.replace 不是函数 Vue.js
【发布时间】:2016-12-28 17:55:38
【问题描述】:
        this.$http.post('../idea/comment'+idea_id, newResponse).then((response) => {
            //do something

            }, (response) => {

            });

        //get returned comment
        //update DOM
       },
     }
 });

所有获取请求都运行良好,但我在尝试发布请求时不断收到此错误。

【问题讨论】:

  • 由于您的代码中没有替换,因此您不能向我们展示正确的块。
  • 尝试将 url 更正为 'idea/comment/' + idea_id

标签: javascript laravel vue.js


【解决方案1】:

发现我做错了什么,我没有正确声明 CSRF 令牌全局。

我这样做了

Vue.http.headers.common['X-CSRF-TOKEN'] = window.Laravel;

而不是

Vue.http.headers.common['X-CSRF-TOKEN'] = window.Laravel.csrfToken;

【讨论】:

    猜你喜欢
    • 2019-03-17
    • 1970-01-01
    • 1970-01-01
    • 2018-04-15
    • 2017-11-19
    • 2019-11-21
    • 1970-01-01
    • 2020-12-16
    • 1970-01-01
    相关资源
    最近更新 更多