我无法使用 laravel-livewire 在 Laravel 8 路由上运行我的代码。
班级在Livewire\LandingPage.
我得到的错误是
属性 [livewire] 不存在
这是我的路线
<?php
use Illuminate\Support\Facades\Route;
Route::livewire('/' , 'LandingPage');
Route::middleware(['auth:sanctum', 'verified'])->get('/dashboard', function () {
return view('dashboard');
})->name('dashboard');
Run Code Online (Sandbox Code Playgroud) 错误:(0, tanstack_react_query__WEBPACK_IMPORTED_MODULE_3 _.useQuery) 不是函数
我正在使用 next js 和 @tanstack/react-query 来获取数据,但在获取数据时出现上述错误。
我所做的代码如下。
这是我用于获取和呈现数据的组件。
import React from 'react'
import ServiceProps from '../interfaces/ServiceProps'
import { fetchServices } from '../api/services/api'
import { useQuery } from "@tanstack/react-query";
const Service = ({ title, content }: ServiceProps) => {
const { data, isLoading, isError, error, } = useQuery({ queryKey: ["fetchServices"], queryFn: fetchServices });
console.log(data)
return (
<div className="dark:bg-transparent rounded-lg dark:border-[#212425] dark:border-2 bg-blue-50 p-8">
{/* <img alt="icon" srcset="/images/icons/icon-1.svg 1x, /images/icons/icon-1.svg 2x" src="/images/icons/icon-1.svg" width="40" height="40" decoding="async" data-nimg="1" className="w-10 h-10 …Run Code Online (Sandbox Code Playgroud) 我在 laravel 8 中使用 React js,我想通过 npm 安装它来使用它,而不使用 laravel ui,但我收到了此错误
在我的迁移文件中,我将组织 id 添加到用户的表中,我尝试了下面的所有代码,但尚未解决
class AddOrganizationIdToUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
// $table->foreignId('organization_id')->references('id')->on('organizations')->onDelete('cascade');
$table->foreignId('organization_id')->constrained('organizations')->cascadeOnDelete();
// $table->foreign('organization_id')->references('id')->on('organizations')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
//
});
}
Run Code Online (Sandbox Code Playgroud)