首页 > 解决方案 > Django - DRF 中的分页在 VueJS 中返回错误

问题描述

目前我在我的 JS 文件中使用 Vue 来使用我的 DRF API。现在当我添加时;

'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
    'PAGE_SIZE': 100

在控制台中,正在返回错误;它说;

 [Vue warn]: Error in render: "TypeError: status is null"
(found in <Root>)
TypeError: "status is null"

HTML中:

<select class="form-control" v-model="newJobRequest.status_of_the_job_request" required >
    <option v-for="status in statusOfTheJobRequests">[[status.type_of_status]]</option>
</select>

JS中:

getStatusOfJobRequest: function() {
    this.loading = true;
    this.$http.get(/api/v1/status-of-the-job-request/).then((response) => {
         this.statusOfTheJobRequests = response.data;
         this.loading = false;
     }).catch((err) => {
         this.loading = false; console.log(err);
     })
 }

由于这个错误,我无法在表格中建立分页。我也在我的用例中使用了 DataTables,但由于这个错误,我无法继续并恢复到原始状态。在可浏览的 API 中,分页没有任何问题。过去两天我一直在寻找答案,但没有发现任何类似的问题,afaik。

标签: djangovue.jsdjango-rest-framework

解决方案


推荐阅读