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