wcqwcq 2020-05-27
<script type="text/javascript"> axios.defaults.baseURL = ‘http://xx.xx.xx.xx‘; axios.defaults.headers.common[‘X-CSRFToken‘] = ‘{{ csrf_token }}‘; Vue.prototype.$http = axios; var app = new Vue({ el: ‘#app‘, data: { res: [], form: { sday: ‘2020-05-27‘, eday: ‘2020-05-27‘, } }, methods: { loadData() { this.$http.post(‘/tongji_plate_entry/‘, app.form) .then(function (response) { if (response.data.result == ‘SUCCESS‘) { app.res = response.data.res; app.form.sday = response.data.sday; app.form.eday = response.data.eday; } }) .catch(function (error) { alert(error); }); } } }); </script>
就是设置axios的headers
axios.defaults.headers.common[‘X-CSRFToken‘] = ‘{{ csrf_token }}‘;
文章分享完毕,希望我的分享对大家有所帮助。更多学习技巧也可参阅:网站源码、模板、教程