使用Django的render返回参数给前端axios,为啥返回的是html界面,有人知道吗
后端代码:
return render(request, 'test.html', res)
前端代码:
<script>
let app = new Vue({
el: "#app",
data: {
//动态数据
tableData: []
},
methods: {
},
mounted: function () {
var _this = this
axios.get('/test/')
.then(function (res) {
console.log("日志res:");
console.log(res);
_this.tableData = res.rlt;
//_this.tableData.push(res.data);
console.log(res.rlt);
})
.catch(function (error) {
console.log(error);
});
},
})
script>
render本来返回的就是带模板(template)内容呀,如果你只需要返回内容的话可以用httpResponse,比如:
return HttpResponse(res)