【发布时间】:2021-01-26 14:20:42
【问题描述】:
我在获取 vuetify 表中的数据时遇到问题,它没有在边表中显示任何数据。
我的 Laravel API
Route::get('/businesslist', 'BusinessController@userlist')->name('businesslist');
Laravel API 控制器
public function businesslist() { $businesslist = Business::paginate(2)->toJson(JSON_PRETTY_PRINT); return response($businesslist); } }
Nuxt 代码
<template> <v-card> <v-card-title> Nutrition <v-spacer></v-spacer> <v-text-field v-model="search" append-icon="mdi-magnify" label="Search" single-line hide-details ></v-text-field> </v-card-title> <v-data-table :headers="headers" :items="registerlist" :search="search" ></v-data-table> </v-card> </template> <script> export default { data () { return { search: '', headers: [ { text: 'SL,No', value: '' }, { text: 'Name', value: 'name' }, { text: 'Mobile ', value: 'mobile_number' }, { text: 'Location ', value: 'location' }, { text: 'Join Date ', value: 'registration_date' }, { text: 'Renewal Date ', value: 'registration_renewal_date' }, ], registerlist: [ ], } axios.get('/Businessregisterlist') .then(res => this.registerlist = res.data.registerlist) }, } </script>
【问题讨论】:
-
在
.then(function(res){})中使用函数,因为this在ES6语法中可以表示全局对象。 -
@Mr.完美主义者能不能把你的答案贴出来让击球手理解
-
好的。给出这个作为答案。
标签: vue.js vuejs2 axios vue-component vuetify.js