Here you go
<div x-data="{ status: false }">
<form>
<input type="hidden" value="0" name="status" x-model.number="status">
<span x-text="status"></span>
<button type="button" x-on:click="status = !status">
Toggle Status
</button>
</form>
</div>
The global status
is held at the div
element. The status is outputted inside a span
using x-text
.
The hidden input
is bound to the status
using x-model
and transforming the boolean
value to a number using the .number
modifier.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…