Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript laravel Livewire wire:单击“不启动”功能_Javascript_Html_Laravel_Typescript_Laravel Livewire - Fatal编程技术网

Javascript laravel Livewire wire:单击“不启动”功能

Javascript laravel Livewire wire:单击“不启动”功能,javascript,html,laravel,typescript,laravel-livewire,Javascript,Html,Laravel,Typescript,Laravel Livewire,我想用laravel livewire做一个SPA,我想用wire:点击启动组件中的功能,但它不工作,请原谅,如果代码弄乱了,这是我第一次在这里发布,我不确定我的代码在这里发布什么来解决这些问题谢谢 main.blade.php @section('content') <div> <div class="row justify-content-center"> <div class="col-12"&g

我想用laravel livewire做一个SPA,我想用wire:点击启动组件中的功能,但它不工作,请原谅,如果代码弄乱了,这是我第一次在这里发布,我不确定我的代码在这里发布什么来解决这些问题谢谢

main.blade.php

@section('content')
<div>
    <div class="row justify-content-center">
        <div class="col-12">
            <div class="card my-3">

                        <!-- header -->
                <div class="card-header d-inline-flex">
                    <h3 class='mr-2'>Categories</h3>
                    <div>
                        <a href="javascript:void(0);" wire:click='createCategory' class="btn btn-success ">Add NewCategory</a>
                    </div>
                </div><!-- header -->
                <div class="card-body">

                    <!-- alerts -->
                    @include('admin.includes.alerts.errors')
                    @include('admin.includes.alerts.success')
                    <!-- alerts -->


                    <!-- if True , create form will show , if not will stay disabled -->
                    @if ($showCreateForm)
                    @livewire('admin.category.create' )
                    @endif
                    <!-- if True , create form will show , if not will stay disabled -->

                    <!-- Table -->
                    <div class="table-responsive">
                        <table id="example2" class="table table-bordered table-hover">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>Image</th>
                                    <th>Name</th>
                                    <th>Slug</th>
                                    <th>Status</th>
                                    <th>Parent</th>
                                    <th>Action</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach ($categories as $category)
                                <tr>
                                    <td>{{$category->id}}</td>
                                    {{-- <td>{{storage_path(app\livewire-tmp\$category->image)}}" /></td> --}}
                                    <td>{{$category->name}}</td>
                                    <td>{{$category->slug}}</td>
                                    <td class=" {{$category->isActive()==='Active'? 'text-success':'text-danger'}}">
                                        {{$category->isActive()}}</td>
                                    <td>{{ !empty($category->parent) ? $category->parent->name:'' }}</td>
                                    <td>
                                        <a href="" class="btn btn-warning">Edit</a>
                                        <a href="" class="btn btn-danger">Delete</a>
                                    </td>
                                </tr>
                                @endforeach

                            </tbody>
                            <tfoot>
                                <tr>
                                    <th>ID</th>
                                    <th>Image</th>
                                    <th>Name</th>
                                    <th>Slug</th>
                                    <th>Status</th>
                                    <th>Parent</th>
                                    <th>Action</th>
                                </tr>
                            </tfoot>
                        </table>
                        <div>
                            {!!$categories->links()!!}
                        </div>
                    </div>
                    <!-- Table -->

                </div><!-- body -->
            </div>
        </div>
    </div>
</div>
@endsection
@节(“内容”)
类别
@include('admin.includes.alerts.errors')
@包括('admin.includes.alerts.success')
@如果($showCreateForm)
@livewire('admin.category.create')
@恩迪夫
身份证件
形象
名称
鼻涕虫
地位
父母亲
行动
@foreach($categories作为$category)
{{$category->id}
{{--{{存储路径(app\livewire tmp\$category->image)}/>-->}
{{$category->name}
{{$category->slug}
{{$category->isActive()}
{{!空($category->parent)?$category->parent->name:''}
@endforeach
身份证件
形象
名称
鼻涕虫
地位
父母亲
行动
{!!$categories->links()!!}
@端部
以及组件Main.php

<?php

namespace App\Http\Livewire\Admin\Category;

use App\Models\Admin\Category;
use Livewire\Component;
use Livewire\WithPagination;

class Main extends Component
{
    use WithPagination;

    protected $categories;
    public $showCreateForm = false;
    public $showEditForm = false;
    public function render()
    {
        $categories = Category::orderBy('id','desc')->paginate(12);
        return view('livewire.admin.category.main',[
            'categories' => $categories,
        ]) ->layout('layouts.admin');
    }

    public function createCategory()
    {
         $this->showCreateForm = !$this->showCreateForm;
    }
    public function update_Category($id)
    {


         $categories = Category::whereId($id);
         if ($categories) {
            $this->emit('getCategoryid' , $categories);
            $this->showEditForm = !$this->showEditForm;
            $this->showCreateForm = false;
         }
    }
    public function delete_Category($id)
    {
         $this->showCreateForm = !$this->showCreateForm;
    }
}

您不需要
:单击
事件可执行此操作,您只需使用:

wire:$toggle('property')
您不需要使用
a
标记;您只需使用
按钮
标记即可。因此,您的按钮代码如下所示:

添加新类别

您不需要
:单击
事件可执行此操作,您只需使用:

wire:$toggle('property')
您不需要使用
a
标记;您只需使用
按钮
标记即可。因此,您的按钮代码如下所示:

添加新类别

我想这会对你有所帮助


我想这会对你有所帮助


在base.blade.php文件中添加liveWire的css和js,它可以工作:

<head>
...
    @livewireStyles
</head>
<body>
    ...

    @livewireScripts
</body>
</html>

...
@livewireStyles
...
@LiveWireScript

在base.blade.php文件中添加liveWire的css和js,它可以工作:

<head>
...
    @livewireStyles
</head>
<body>
    ...

    @livewireScripts
</body>
</html>

...
@livewireStyles
...
@LiveWireScript


所有HTML代码都应该用single
覆盖,然后它就会工作。

所有HTML代码都应该用single
覆盖,然后它就会工作。

欢迎这么做,你说不工作是什么意思,告诉更多关于显示错误的信息卡头中的链接应该去运行Main.php组件中的函数,所以当我点击它时,它不会做任何事情控制台中有任何错误吗?网络中没有任何事情,控制台中也没有错误检查网络选项卡,它是否发送任何东西?欢迎访问,不工作是什么意思,告诉更多关于错误的信息,显示在卡头中的链接应该转到Main.php中并运行函数组件,所以当我点击它时,它不会做任何事情你的控制台中有任何错误吗?网络中没有任何事情发生,控制台中也没有任何错误检查网络选项卡,它发送任何东西吗?谢谢你的回复,我会尝试它,并验证它是否工作,伙计,我认为它是javascript的事情,因为它根本没有响应一个被禁用的链接很奇怪,你包括livewire的css和js吗?请提供页面的完整代码,包括布局页面谢谢你的回复,我会试试看,如果它能正常工作还是不能正常工作,伙计,我认为它是javascript的东西,因为它根本不像一个被禁用的链接那样响应。很奇怪,你包括liv吗ewire的css&js?请提供页面的完整代码,包括布局页面。它对我有用,谢谢你让我开心!谢谢你它对我有用,谢谢你让我开心!谢谢