问题标签 [laravel-livewire]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
756 浏览

javascript - Live-wire - 实时聊天没有正确响应

我正在尝试使用 live-wire 来看看如何在我即将到来的项目中实现它。这个想法是一个简单的聊天(用户输入正文并单击发送,然后消息将在聊天的底部)

到目前为止一切正常,直到我点击发送按钮。

这是我点击发送之前的图片 在此处输入图像描述

这是我点击发送后发生的事情

在此处输入图像描述

我觉得问题出在这部分代码中,我将消息发送到火线刀片

这是组件

}

最后是监听事件组件:

检查日志中的问题是

Uncaught (in promise) TypeError: Cannot read property 'data' of null 但我认为它与聊天数据无关!

提前致谢

0 投票
1 回答
2959 浏览

laravel - 打字时如何忽略laravel livewire组件上的重新渲染

我有一个向导表单,它是一个 livewire 组件,它总是在我打字时重新呈现。我想在提交表单之前停止重新渲染。

谁能帮帮我?抱歉英语不好,我是法国人。

0 投票
3 回答
5084 浏览

php - 如何仅将加载状态应用于 livewire 中的特定组件

我在我的项目中使用 Laravel Livewire,我wire:loading用于在单击时加载状态。我迭代了 foreach 循环中的所有任务,但加载状态适用于所有组件。这是代码。

在此处输入图像描述

刀片文件

GitLab:https ://gitlab.com/tasklog/tasklog/-/blob/master/resources/views/livewire/home/tasks.blade.php

控制器文件

GitLab:https ://gitlab.com/tasklog/tasklog/-/blob/master/app/Http/Livewire/Home/Tasks.php

0 投票
1 回答
520 浏览

javascript - 搜索文本修剪脚本后 livewire 不起作用“...查看更多”

搜索后

我正在使用脚本来修剪部分帖子和按钮“..查看更多”。在第一页加载时,一切正常,但在搜索几乎所有帖子后,脚本不起作用。有人能帮我吗?

对不起我的英语不好

0 投票
2 回答
1954 浏览

javascript - Laravel Livewire and Cashier double form submit issue

I'm trying to get Cashier to work with Livewire and I'm running into an error where I have to press the submit button twice to get the paymentmethod .

In this video: https://www.loom.com/share/cb27ce3ae8ab46fab27e68afc7900eb4

I'm trying to dd(); the following.

Everything is returned on the first submission except to the $this->paymentmethod I have to submit the form a 2nd time for $this->paymentmethod to return in the dd();

Note I do not refresh the page on the 2nd form submission.


Here is the relevant code:

Livewire View:


Livewire Controller:

Any help on how to fix this would be appreciated.

0 投票
0 回答
287 浏览

laravel-livewire - Livewire 按钮不会点击

我正在尝试制作一个功能按钮。当我单击按钮时,它不会显示输出这是我的按钮视图

<button wire:click="edit({{ $data->id }})" class="btn btn-primary btn-sm">Edit</button>

这是我的功能

public function edit($id){ dd('$id');}

这是我的布局

0 投票
1 回答
878 浏览

laravel - 如何获取 livewire 渲染分页方法中的所有行数?

在我使用 livewire/livewire 1.3 的 laravel 7 应用程序中,我在组件中使用分页:

我还需要获取相关表中所有行的数量,我该如何使用上面的方法呢?

0 投票
1 回答
1223 浏览

php - Laravel Livewire Same Component Two Items Sync in One Page

I made follower component.

If visitor follows a author, then component will show Following and if not, it will show Follow.

I put follower component in two places of page.

-follower component.

public $following = true; public $post;

I am using this component in two places in one page.

When I click one component, it was toggled and worked well.

But the other component keeps old state.

How can I sync them?

Thank you

0 投票
1 回答
531 浏览

php - 返回 JSON 而不是使用数据绑定重新渲染组件

我创建了一个组件来根据输入框中的初始值计算小费,在本例中为 $amount。我已经开始使用 Livewire 来了解它,安装和配置没有问题,但是当我使用数据绑定从输入框渲染 $amount 时,Laravel 返回 JSON 而不是重新渲染插入的组件价值。在控制台检查它会发送一个 POST 并返回一个 200 代码,但在打开它时会显示 419 错误代码。我正在使用 Bulma 作为 CSS 框架

提示计算器.php

提示计算器.blade.php

欢迎.blade.php

0 投票
3 回答
15248 浏览

javascript - 为什么未触发 livewire 发出的事件?

在 laravel 7 学习 livewire/livewire 1.3 我遇到了发出的事件并不总是被触发

我用命令创建了组件

并简化我没有看到事件警报的代码。在 app/Http/Livewire/Hostel/HostelsHomepageSpotlight.php 中:

在资源/视图/livewire/hostel/hostels-homepage-spotlight.blade.php 中:

为什么没有触发事件?有没有办法调试它?

更新#2: 我知道关于包装 div 的规则(没有任何类或样式定义)。我也要删除 JS 代码吗?

我试图在 resources/js/app.js 中移动所有 JS 代码:

在我的资源/视图/布局/app.blade.php 中:

而且我的代码无论如何都不会触发!我想这是我的应用程序在@livewireStyles 和@livewireScripts 之后作为app.js 的有效结构

更新#3:

我试过了,但这不起作用。我有登录表格:

当@push/@endpush 在上面的行中被注释时,它可以正常工作,并且焦点设置为电子邮件输入。但是,如果取消注释这两条线,则焦点未设置。

我修改了资源/视图/布局/app.blade.php:

app.js - 首先是引导程序和 jquery 包含在其中...

谢谢!