mirror of https://github.com/sveltejs/svelte
parent
c8294cc632
commit
a9ffe159ec
@ -1,33 +1,35 @@
|
||||
<script>
|
||||
let check = $state(true);
|
||||
|
||||
let check_bindings = [
|
||||
() => check,
|
||||
(v) => {
|
||||
console.log('check', v);
|
||||
check = v;
|
||||
}
|
||||
];
|
||||
const get = () => check;
|
||||
const set = (v) => {
|
||||
console.log('check', v);
|
||||
check = v;
|
||||
};
|
||||
const bindings = [get, set];
|
||||
const nested = {deep: {
|
||||
bindings: [get, set],}
|
||||
};
|
||||
|
||||
function getArrayBindings() {
|
||||
console.log('getArrayBindings');
|
||||
return check_bindings;
|
||||
return [get, set];
|
||||
}
|
||||
|
||||
function getObjectBindings() {
|
||||
console.log('getObjectBindings');
|
||||
const [get, set] = check_bindings;
|
||||
return { get, set };
|
||||
}
|
||||
</script>
|
||||
|
||||
<input type="checkbox" bind:checked={get, set} />
|
||||
|
||||
<input type="checkbox" bind:checked={check_bindings[0], check_bindings[1]} />
|
||||
<input type="checkbox" bind:checked={...bindings} />
|
||||
|
||||
<input type="checkbox" bind:checked={...check_bindings} />
|
||||
<input type="checkbox" bind:checked={...nested.deep.bindings} />
|
||||
|
||||
<input type="checkbox" bind:checked={...getArrayBindings()} />
|
||||
|
||||
<input type="checkbox" bind:checked={...(() => check_bindings)()} />
|
||||
<input type="checkbox" bind:checked={...(() => [get, set])()} />
|
||||
|
||||
<input type="checkbox" bind:checked={...getObjectBindings()} />
|
||||
|
Loading…
Reference in new issue