简体   繁体   中英

Laravel 8 Livewire wire:click:prevent Not Working

Please Someone please I am in the middle of my final year project but this is not working I am trying for 3 days I am new so I don't know how to ask a question so if you need something please ask me Thanks This is the view for Shop and i have used Composer require Hardevine/shoppingcart

在此处输入图像描述

This is the ShopComponent for Shop

在此处输入图像描述

Instead Of This

wire:click:prevent=“store({{$product->id}},’{{$product->name}}’,{{$product->regular_price}})”

You need to use this in your blade file

@livewireStyles
    your code will be in this area
@livewireScripts

Try This For Calling Store Function

wire:click.prevent="store({{$product->id}},{{$product->name}},{{$product->regular_price}})”

Or

wire:click="store({{$product->id}},{{$product->name}},{{$product->regular_price}})”

When I ran Laravel 8 on IIS, I had a similar problem. The problem was that the browser couldn't access some of the livewire js files, and the solution was:

Go to D:\Projects\Laravel\laravel8ecommerce\vendor\livewire\livewire\config\livewire.php and set

'asset_url' => "your_url",

and the problem was disappeared.

I had same problem. To solve this issue what I did was enclose my blade template files with a <div> containing an id="main" like so:

<div id=main>
  your blade template code
<div>

My solution was based on @KumTem answer

Inside the livewire blades located at app\resources\views\livewire\sample_blade.php

<div id="main">
... templates here
</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM