我用这个循环
\n<form action="/" method="POST">\n <template x-for="(deck, index) in $store.cart.decks">\n <div x-show="$store.cart.total(index) > 0">\n <div><span x-text="$store.cart.total(index)"></span> Karten</div>\n <div x-text="deck.price"></div> \xe2\x82\xac\n <input :name="'deck[' + index + '][name]'" :value="$store.cart.decks[index].name">\n </div>\n </template>\n</form>\nRun Code Online (Sandbox Code Playgroud)\n它工作正常,显示我购物车中的所有商品,并隐藏总数为 0 的商品。
\n但这只会将项目设置为 0 display:none,但仍会传输 POST 请求中的数据。
我尝试使用x-if代替x-show,但这只允许在模板标签上使用。
我尝试在模板标签上添加 x-if:
\n<template x-show="$store.cart.total(index) > 0" ...\nRun Code Online (Sandbox Code Playgroud)\n这会导致错误,因为index此时尚未设置
我尝试<template>在现有模板中添加另一个标签,但变量index和deck在第二个模板中不再可用
如何防止在我的 POST 请求中计算零购物车商品?
\n目标
我希望即使子元素被禁用,父元素也可单击。
示例代码
const parent = document.getElementById('parent');
parent.addEventListener('click', (e) => {
console.log('hello world')
}, true);Run Code Online (Sandbox Code Playgroud)
<div id="parent">
<input disabled placeholder="foo">
</div>Run Code Online (Sandbox Code Playgroud)
重要的提示
@Drag13 向我指出它可以在Chrome 96. 它不适用于Firefox 95.0Linux 操作系统。
提前致谢!
根据Vaadin 提供的文档和演示,路由参数应该绑定到 location.params。提供的示例使用聚合物,当我使用 LitElement 时,location.params 未定义。除了使用 JavaScript 结合 Lit 来解析 url 以提取使用的 url :parameter 之外,还有其他技巧吗?
我正在创建一个显示一些数据的索引表单。一切准备就绪,但当我按下删除按钮时,出现错误“此路线不支持 DELETE 方法。支持的方法:GET、HEAD、POST。”
路线
Route::group(['middleware' => ['auth']], function() {
Route::resource('roles','RoleController');
Route::resource('users','UserController');
Route::resource('kamar_theresia','Kamar_TheresiaController');
});
Run Code Online (Sandbox Code Playgroud)
控制器
public function destroy($id)
{
Kamar_Theresia::find($id)->delete();
return redirect()->route('kamar_theresia.index')
->with('success','Kamar Theresia deleted successfully');
}
Run Code Online (Sandbox Code Playgroud)
看法
@foreach ($kamar_theresia as $tere)
<tr>
<td>{{ ++$i }}</td>
<td>{{ $tere->nama }}</td>
<td>{{ $tere->name }}</td>
<td>{{ $tere->ketersediaan }}</td>
<td>
@can('theresia-delete')
{!! Form::open(['method' => 'DELETE','route' => ['kamar_theresia.destroy', $tere->id],'style'=>'display:inline']) !!}
{!! Form::submit('Delete', ['class' => 'btn btn-danger']) !!}
{!! Form::close() !!}
@endcan
</td>
</tr>
@endforeach
Run Code Online (Sandbox Code Playgroud) 我有一个输入来输入标签。每门课程都会有很多标签,我想将这些标签保存在同一列中。
输入
<div class="card border-grey border-lighten-3 px-2 py-2 box-shadow-1 mt-1">
<h4 class="content-header-title"> Tags </h4>
<select name="tags[]" data-tags="true" id="tags" class="form-control" multiple="multiple">
<option value=""></option>
</select>
</div>
Run Code Online (Sandbox Code Playgroud)
脚本选择2
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.10/js/select2.min.js"></script>
<script>
$(document).ready(function(){
$('#tags').select2({
placeholder: "Tags",
tags: true
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
控制器
function save(Request $request)
{
$lesson = new Lesson;
$lesson->tags= $request->input('tags');
$lesson->content = $request->content;
$lesson->save();
return redirect(url('admin/lessons/edit'))->with('message', 'Successful');
}
Run Code Online (Sandbox Code Playgroud)
但是当我点击保存时,出现这样的错误:
传递给 Illuminate\Database\Grammar::parameterize() 的参数 1 必须是给定的数组、字符串类型,在 C:\Xampp-install\htdocs\eduwebsite\vendor\laravel\framework\src\Illuminate\Database\Query 中调用\Grammars\Grammar.php 第 869 行
要求就像从邮递员发送一个json对象,我需要在restcontroller上接收它并使用spring boot将整个json对象保存到mysql数据库表列(在一个/单列中)。
{
"name" : "abc",
"address : "xyz"
}
Run Code Online (Sandbox Code Playgroud)
假设上面的 json 对象从邮递员发送到 Spring Boot RestController。我如何将该 json 对象保存在表的列中。
在 config/cors.php 文件中我有键值对
'supports_credentials' => false,
“supports_credentials”对于 true 有何作用,对于 false 有何作用?
我通过WSL2和Sail在 Windows 10 上将Laravel 8与Docker结合使用。我创建了一个 CRUD 来在数据库中存储一些带有图像的文章。我正在尝试显示来自 Laravel 存储的图像,但它们没有出现在浏览器中。我怎样才能解决这个问题?
文章控制器.php
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return view('admin.articles.create');
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$validatedData = $request->validate([
'title' => 'required',
'body' => 'required',
'author' => 'required',
'image' => 'nullable | image …Run Code Online (Sandbox Code Playgroud) 当尝试使用 Laravel Cashier 取消订阅时,它返回错误:
找不到类“App\Models\User”
代码:
public function cancel(Request $request) {
$subscription = Auth::user()->subscription('default');
$subscription->cancel();
}
Run Code Online (Sandbox Code Playgroud)
这可能是因为我的用户模型不位于“App\Models\User”(Laravel 8 中的新默认值),而是位于“App\User”。
在官方文件中,提到了这一点:
如果您使用的模型不是 Laravel 提供的 App\Models\User 模型,则需要发布并更改提供的 Cashier 迁移以匹配替代模型的表名称。
但这不是问题。我的表名是相同的,但我的模型的位置不同。
我该如何解决?
我的目标是在显示和隐藏 HTML 元素时创建动画。显示和隐藏由切换类隐藏的按钮触发。
这是我的代码:
const button = document.querySelector('button');
const box = document.querySelector('.box');
button.addEventListener('click', () => {
box.classList.toggle('hide');
})Run Code Online (Sandbox Code Playgroud)
.box {
width:200px;
height: 200px;
border: 1px solid #000;
background-color: gray;
margin: 0 auto;
opacity: 1;
display: block;
}
.hide {
display: none;
transition: all 1s ease-out;
opacity: 0;
}Run Code Online (Sandbox Code Playgroud)
<button>Show / Hide</button>
<div class="box hide"></div>Run Code Online (Sandbox Code Playgroud)
laravel ×5
javascript ×3
html ×2
php ×2
alpine.js ×1
css ×1
forms ×1
java ×1
laravel-8 ×1
laravel-sail ×1
lit ×1
mysql ×1
spring-boot ×1
storage ×1
templates ×1