当前位置: 首页 > 知识库问答 >
问题:

为什么布线:单击“不在laravel livewire中工作”

林亦
2023-03-14

laaravel版本: 8.0
livewire版本: 2. x

嗨那里

我是新加入laravel livewire的,面临着一个奇怪的问题!。为了执行操作,我使用了wire:click,这可以在我的管理员登录中的以下代码中看到。刀身php

@section('content')
<div class="admin-login display-flex  flex-align-items-center flex-justify-content-center">
    <button wire:click="toDo">{{$login}}</button>
    <div class="admin-form display-flex flex-direction-column flex-justify-content-center" >
        @livewire('header',['name'=> 'Admin Login','width'=> '100%','height' => '20%'])
    <form  class=" display-flex flex-direction-column flex-justify-content-center"  >
        <section style="margin: 2%;">
        <label for="Email">Email :<span style="color: red">*</span></label>
        <input type="email" required>
        </section>
        <section style="margin: 2%;">
            <label for="Password">Password :<span style="color: red">*</span></label>
            <input type="password" required>
        </section>

            <button  style="width: 40%; height: 5vh; align-self: center;justify-self: flex-end;">Login</button>

    </form>
    </div>
</div>
@endsection

我的应用程序。刀身layouts目录中的php文件是

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="{{asset('css/admin/app.css')}}">
    @livewireStyles

    <title>Admin Dashboard</title>


</head>
<body>
@livewire('nav-bar')
@livewire('side-bar')
@yield('content')
</body>

@livewireScripts

<script>
    var isStudentDropDown = false
    Livewire.on('showSidebar',()=>{
        document.getElementById('sidebar').style.display = "block"
    })
    Livewire.on('closeSidebar',()=> {
        document.getElementById('sidebar').style.display = "none"
    })
    Livewire.on('showDropdown',data => {
        if(document.getElementById(data).style.display === "block"){
            document.getElementById(data).style.display = "none"
        }else{
            document.getElementById(data).style.display = "block"
        }

    })
</script>

</html>

现在是我的组件php文件

<?php

namespace App\Http\Livewire;

use Livewire\Component;

class AdminLogin extends Component
{
    public $login = "login";
    public function render()
    {
        return view('livewire.admin-login');
    }
    public function hell(){
       $this->login = "signup";
    }
    public function toDo(){
        dd('do some thing');
    }
}

我已经检查了我的devtools,没有收到发送到服务器的请求

原谅我的任何错误!

共有1个答案

燕扬
2023-03-14

参考链接https://laravel-livewire.com/docs/2.x/rendering-components#custom-布局

public function render()
{
   return view('livewire.admin-login')
   ->extends('layouts.app')
   ->section('content');
}

和删除@部分admin-login.blade.php

 类似资料:
  • 在我的应用程序中,我在menuitemclicked中添加了Observable方法,但当我点击它两次时,它仍然起作用。单次按压。方法不工作,但按钮工作良好,任何建议或方法中的任何更改。 fetch()中断; }

  • 我还可以用 我得到一条消息,说测试通过了,但从未显示在屏幕上。为什么不呢?

  • 按钮单击在selenium webdriver中不工作。 尝试使用类名和xpath。 提交订单

  • 当我调用下面的代码时,我总是得到 用户的值。Id和密码有效。结果错误总是说“无效令牌”,我没有尽可能地看到它,因为我得到它并立即检查它和它的错误。这只是一个理智测试——我通常通过电子邮件向用户发送令牌,但这也不起作用。 UPDATE 1我在同一个控制器中定义UserManager,如下所示: UPDATE 2这是我的Application ationUserManager代码:

  • 我点击图片,弹出效果很好。但是,当我在弹出窗口外单击时,iframe allowfullscreen和frameborder属性将被删除。我再次点击弹出窗口,全屏工作,有一条白线。我希望弹出停止视频播放一旦关闭和iframe返回没有src和保留其属性。 我试过: 使用JavaScript/jQuery更新属性 通过JavaScript/jQuery替换html(已注释掉) HTML

  • 本文向大家介绍` 单击 `和` 单击 `有什么区别?相关面试题,主要包含被问及` 单击 `和` 单击 `有什么区别?时的应答技巧和注意事项,需要的朋友参考一下 绑定函数有三种方法 1、constructor绑定 2. 使用时绑定 3. 使用箭头函数 这种最简单 不用考虑this的指向问题 (但是会造成额外的渲染) 以上三种方法,第一种最优。 因为第一种构造函数只在组件初始化的时候执行一次, 第二种

  • 在此输入图像说明 我正在尝试用新文本更新并且我需要这个文本有下行线。

  • 上下文:我正在设计一个应用程序,它将使用来自各种Amazon SQS队列的消息。(超过25个队列)为此,我正在考虑创建一个库来使用队列中的消息(称为MessageConsumer) 我希望根据队列中的流量动态分配线程来接收/处理来自不同队列的消息,以最大限度地减少资源浪费。我有两种方法可以做这件事。 1)只能有一种类型线程轮询队列、接收消息并处理这些消息,且所有队列都有一个公共线程池。2)可以有单