КС
Та и где у инпутов не строковые валью?
Size: a a a
КС
МТ
МТ
КС
МТ
МТ
КС
КС
<Input bind:value={survey.value} type={survey.type} />
и всёКС
МТ
<script lang="ts">
export let label = '';
export let placeholder = '';
export let value: string | number = '';
export let type = 'text';
function handleInput(event: Event): void {
const { value: inputVal } = event.target as HTMLInputElement;
if (type === 'number') {
value = inputVal === '' ? 0 : +inputVal;
} else {
value = inputVal;
}
}
</script>
{#if label}
<label class="input {$$restProps.class || ''}">
<span>{label}</span>
<input {type} value={value || ''} on:input={handleInput} />
</label>
{:else}
<input
class="input {$$restProps.class || ''}"
{type}
{placeholder}
value={value === 0 ? '' : value}
on:input={handleInput}
/>
{/if}
<style lang="scss">
label, input {
display: block;
}
</style>
КС
МТ
МТ
МТ
КС
node.type = type
- бесполезная хрень, которая ничего не даётКС
{#each surveys as survey}хочешь делать Meh и не брать какие-то убогие компоненты к себе в проект и хочешь юзать бинды - делаешь вот так
{#if survey.type === 'text'}
<input bind:value={survey.value} />
{:else if survey.type === 'number'}
<input type="number" bind:value={survey.value} />
{/if}
{/each}
PM
PM
r
{#each surveys as survey}хочешь делать Meh и не брать какие-то убогие компоненты к себе в проект и хочешь юзать бинды - делаешь вот так
{#if survey.type === 'text'}
<input bind:value={survey.value} />
{:else if survey.type === 'number'}
<input type="number" bind:value={survey.value} />
{/if}
{/each}