作者:手机用户2602931131 | 来源:互联网 | 2023-08-28 11:51
这是我第一次使用laravel Vue和axios。我试图将“订阅”按钮添加到我的用户频道。它不在axios中返回订户响应吗?我的response.data是否错误或模板中的输出是否正确?任何帮助都会很好。如果需要,我可以提供更多代码。谢谢
AppSubscribeButton.vue
{{ subscribers }} Subscribe
我的web.php
Route::get('/','HomeController@index')->name('home');
Route::get('/channel/{channel}','ChannelController@show');
Route::get('/subscription/{channel}','ChannelSubscriptionController@show');
Auth::routes(['verify' => true]);
Route::group(['middleware' => ['verified']],function() {
Route::group(['prefix' => 'account','middleware' => ['auth'],'as' => 'account.'],function () {
/**
* account
*/
Route::get('/','account\accountController@index')->name('index');
/**
* Profile
*/
Route::get('profile','account\ProfileController@index')->name('profile');
Route::post('profile','account\ProfileController@store')->name('profile.store');
/**
* Password
*/
Route::get('password','account\PasswordController@index')->name('password');
Route::post('password','account\PasswordController@store')->name('password.store');
});
/**
* Dashboard
*/
Route::get('/dashboard','DashboardController@index')->name('dashboard');
/**
* Teams
*/
Route::resource('teams','Teams\TeamController');
Route::get('teams/{team}/delete','Teams\TeamController@delete')
->name('teams.delete');
Route::get('teams/{team}/users/{user}/delete','Teams\TeamUserController@delete')
->name('teams.users.delete');
Route::resource('teams/{team}/users','Teams\TeamUserController')->names([
'index' => 'teams.users.index','store' => 'teams.users.store','destroy' => 'teams.users.destroy',]);
Route::get('teams/{team}/users/{user}/roles','Teams\TeamUserRoleController@edit')
->name('teams.users.roles.edit');
Route::patch('teams/{team}/users/{user}/roles','Teams\TeamUserRoleController@update')
->name('teams.users.roles.update');
/**
* Channels
*/
Route::group(['middleware' => ['auth']],function () {
Route::get('/channel/{channel}/edit','ChannelSettingsController@edit');
Route::put('/channel/{channel}/edit','ChannelSettingsController@update');
Route::get('/createchannel','ChannelCreateController@index')->name('createchannel');
Route::put('/createchannel','ChannelCreateController@store')->name('createchannel.store');
Route::get('/channel/{channel}/delete','ChannelSettingsController@index');
Route::delete('/channel/{channel}/delete','ChannelSettingsController@destroy')->name('createchannel.destroy');
});
});
如果我console.log(订阅者)出现此错误
[Vue warn]: Error in mounted hook: "ReferenceError: subscribers is not defined"
found in
---> at resources/js/components/AppSubscribeButton.vue
app.js:38444:15
warn http://teams.com:8000/js/app.js:38444
logError http://teams.com:8000/js/app.js:39703
globalHandleError http://teams.com:8000/js/app.js:39698
handleError http://teams.com:8000/js/app.js:39658
invokeWithErrorHandling http://teams.com:8000/js/app.js:39681
callHook http://teams.com:8000/js/app.js:42024
insert http://teams.com:8000/js/app.js:40956
invokeInsertHook http://teams.com:8000/js/app.js:44145
patch http://teams.com:8000/js/app.js:44362
_update http://teams.com:8000/js/app.js:41750
updateComponent http://teams.com:8000/js/app.js:41871
get http://teams.com:8000/js/app.js:42282
Watcher http://teams.com:8000/js/app.js:42271
mountComponent http://teams.com:8000/js/app.js:41878
$mount http://teams.com:8000/js/app.js:46848
$mount http://teams.com:8000/js/app.js:49733
_init http://teams.com:8000/js/app.js:42816
Vue http://teams.com:8000/js/app.js:42882
js http://teams.com:8000/js/app.js:49869
__webpack_require__ http://teams.com:8000/js/app.js:20
0 http://teams.com:8000/js/app.js:50007
__webpack_require__ http://teams.com:8000/js/app.js:20
http://teams.com:8000/js/app.js:84
http://teams.com:8000/js/app.js:87