简体   繁体   English

Laravel 8 Jetstream || 未定义变量:_instance(查看:C:\\xampp\\htdocs\\veye-website\\resources\\views\\vendor\\jetstream\\components\\modal.blade.php

[英]Laravel 8 Jetstream || Undefined variable: _instance (View: C:\xampp\htdocs\veye-website\resources\views\vendor\jetstream\components\modal.blade.php

I am trying to use Laravel 8 Livewire Modal Popup for data entry with going on another page.我正在尝试使用 Laravel 8 Livewire Modal Popup 进行数据输入并进入另一个页面。 But I get undefine the variable _instance and not able to understand it.但是我没有定义变量 _instance 并且无法理解它。

@entangle($attributes->wire('model')) @entangle($attributes->wire('model'))

This line creates this error when I remove this from views/vendor/jetstream/components/modal.blade.php.当我从 views/vendor/jetstream/components/modal.blade.php 中删除它时,这一行会产生此错误。 the error will go.错误会消失。

Line no 34. 34号线。

<div id="<?php echo e($id); ?>" x-data="{ show: <?php if ((object) ($attributes->wire('model')) instanceof \Livewire\WireDirective) : ?>window.Livewire.find('<?php echo e($_instance->id); ?>').entangle('<?php echo e($attributes->wire('model')->value(

    x-show="show"

    x-on:close.stop="show = false"

    x-on:keydown.escape.window="show = false"

    class="fixed top-0 inset-x-0 px-4 pt-6 sm:px-0 sm:flex sm:items-top sm:justify-center"

    style="display: none;">

This was causing me much angst too but I think I found the solution: as @georgy-malanichev says, you can only call Livewire methods from inside a Livewire component (and not from inside a Blade component or any other custom components).这也让我很焦虑,但我想我找到了解决方案:正如@georgy-malanichev 所说,您只能从Livewire组件内部(而不是Blade组件或任何其他自定义组件内部)调用 Livewire 方法。

Given you are trying to use the component inside resources/views/dashboard.blade.php , the solution is to:鉴于您正在尝试使用resources/views/dashboard.blade.php的组件,解决方案是:

  1. create a livewire component using artisan make:livewire MyDashboard使用artisan make:livewire MyDashboard创建一个 livewire 组件artisan make:livewire MyDashboard
  2. Cut everything between <x-app-layout> and </x-app-layout> in dashboard.blade.php and paste it into views/livewire/my-dashboard.blade.php剪切dashboard.blade.php <x-app-layout></x-app-layout>之间的所有内容并将其粘贴到views/livewire/my-dashboard.blade.php
  3. Add @livewire('my-dashboard') inside the x-app-layout tags and Bob's your uncle (it should start working)x-app-layout标签中添加@livewire('my-dashboard')并且 Bob 是你的叔叔(它应该开始工作)

To help you understand what's going on, if you look at the source code for the modal component, you'll see a line like: show: @entangle($attributes->wire('model')), .为了帮助您了解发生了什么,如果您查看模态组件的源代码,您将看到如下一行: show: @entangle($attributes->wire('model')), I'm not sure how to describe exactly what this does, but, essentially, @entangle() is expecting an instance of the "model" Livewire object and it's not finding one.我不确定如何准确描述它的作用,但本质上, @entangle()期待“模型”Livewire 对象的实例,但它没有找到。

It's not finding it because it's getting called from a non-livewire component.它没有找到它,因为它是从非 livewire 组件调用的。 Once you put it inside a Livewire component, it starts working.一旦你把它放在一个 Livewire 组件中,它就会开始工作。

I hope the additional details makes things clearer.我希望额外的细节能让事情更清楚。

I was getting the same error but in my case it was the fact that I had x-data="{ open: @entangle('showDropdown') }" outside of the LiveWire component.我遇到了同样的错误,但就我而言,这是因为我在 LiveWire 组件之外x-data="{ open: @entangle('showDropdown') }" Once I moved it inside the component template, where it should be, the issue went away.一旦我将它移到组件模板中,它应该在的位置,问题就消失了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Laravel 中未定义的变量 $staffs(视图:C:\\xampp\\htdocs\\staffRecords\\resources\\views\\dashboard.blade.php) - Undefined variable $staffs (View: C:\xampp\htdocs\staffRecords\resources\views\dashboard.blade.php) in laravel 未定义变量:UserRegistration(查看:C:\xampp\htdocs\laravel\Form_submit\resources\views\registration.blade.php) - Undefined variable: UserRegistration (View: C:\xampp\htdocs\laravel\Form_submit\resources\views\registration.blade.php) 未定义的变量:用户(查看:C:\\ xampp \\ htdocs \\ rentalmobil \\ resources \\ views \\ admin \\ user.blade.php) - Undefined variable: users (View: C:\xampp\htdocs\rentalmobil\resources\views\admin\user.blade.php) 未定义的变量:技能(视图:C:\\ xampp \\ htdocs \\ apcjobs \\ resources \\ views \\ skillsemployee \\ skillsdatabase \\ skills.blade.php) - Undefined variable: Skills (View: C:\xampp\htdocs\apcjobs\resources\views\skillsemployee\skillsdatabase\skills.blade.php) 未定义变量:id(查看:C:\xampp\htdocs\FYP\DigitalOPDATM\resources\views\pupdate.blade.php) - Undefined variable: id (View: C:\xampp\htdocs\FYP\DigitalOPDATM\resources\views\pupdate.blade.php) 如何修复“未定义变量:gambar(查看:C:\xampp\htdocs\apmt\resources\views\upload.blade.php) - How to fix "Undefined variable: gambar (View: C:\xampp\htdocs\apmt\resources\views\upload.blade.php) “未定义的变量:类别(视图:C:\\ xampp \\ htdocs \\ blog \\ resources \\ views \\ partials \\ _popular.blade.php)” - “Undefined variable: categories (View: C:\xampp\htdocs\blog\resources\views\partials\_popular.blade.php) ” 未定义的变量:帖子(查看:C:\\ xampp \\ htdocs \\ practiseapp \\ resources \\ views \\ dashboard.blade.php) - Undefined variable: posts (View: C:\xampp\htdocs\practiseapp\resources\views\dashboard.blade.php) 未定义变量:artikel(视图:C:\\xampp\\htdocs\\uts\\resources\\views\\layouts\\home.blade.php) - Undefined variable: artikel (View: C:\xampp\htdocs\uts\resources\views\layouts\home.blade.php) Laravel v5.6错误显示此“未定义的偏移量:0(视图:C:\\ xampp \\ htdocs \\ schoolmanagement \\ resources \\ views \\ displaycombinedata.blade.php)” - Laravel v5.6 error showing this “Undefined offset: 0 (View: C:\xampp\htdocs\schoolmanagement\resources\views\displaycombinedata.blade.php)”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM