【发布时间】:2017-04-10 01:21:13
【问题描述】:
我正在使用 Laravel 5.3 和 vue.js 2.0,
我使用 axios (https://github.com/mzabriskie/axios) 发送 ajax 请求,
我按照文档将TOKEN 设置为这样:
<script>
axios.defaults.headers.common['Authorization'] = AUTH_TOKEN; //The error is at this line.
new Vue({
el: "#app",
data: function () {
return {
items: []
}
},
mounted: function () {
this.$nextTick(function () {
axios.get('/articles').then(function (response) {
response.data.forEach(function (item) {
item.selected = false;
});
this.items = response.data;
}).catch(function (error) {
console.log(error);
});
});
}
});
</script>
控制台报错如下:
Uncaught ReferenceError: AUTH_TOKEN is not defined
我该怎么办?
【问题讨论】: