Laravel 8 Jetstream Livewire 密码确认模式不起作用

问题描述

我是 Livewire 的新手,我正在尝试使用 Jetstream/Livewire/TailwindCSS 在 Laravel 8 中使用模式密码确认。在向用户提供一些敏感信息之前,我想这样做作为额外的保护层。根据 https://jetstream.laravel.com/2.x/features/password-confirmation.html (#Modal Confirmation Via Livewire) 中的文档,我应该能够创建一个组件,然后在执行我的其余代码之前调用该操作以请求密码确认。但是,我无法使其正常工作。
我的组件(\App\Http\Livewire\TestComponent.PHP):

<?PHP

namespace App\Http\Livewire;

use Livewire\Component;

class TestComponent extends Component
{
    public function doSomething(){
        $this->ensurePasswordisConfirmed();
        //do something here to provide sensitive information,but for Now:
        dd('hello world');
    }
}

和我的视图文件

<!-- some other stuff -->
<x-jet-confirms-password wire:then="doSomething">
    <x-jet-button type="button" wire:loading.attr="disabled">
        {{ __('Click Me') }}
    </x-jet-button>
</x-jet-confirms-password>
<!-- rest of page -->

我希望点击按钮并显示密码确认模式,但 UI 上没有任何反应,控制台显示如下错误

Alpine:无法在 Livewire 组件外部引用“$wire”(在 SupportAlpine.js 中)

Alpine 错误:“类型错误:null 不是对象(正在评估 'wireEl.__livewire')” 表达式:“$wire.startConfirmingPassword('88430b463c8820be758732f8dbb3f7de')” (在 app.js 中)

未处理的承诺拒绝:TypeError:null 不是对象(正在评估 'wireEl.__livewire')(在 SupportAlpine.js 中)

页面上的其他组件工作正常。我不知道我错过了什么,但我确定这一定是非常简单的事情。有任何想法吗?这将不胜感激。提前致谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...