【发布时间】:2019-08-05 07:28:53
【问题描述】:
加载包含输入文件的组件后。我怎样才能专注于那个特定领域?
TextField.svelte
<script>
export let label = ''
export let name = ''
export let placeholder = ''
export let value = ''
</script>
<div class="field">
<label for={name}>{label}</label>
<input {placeholder} type="text" {name} bind:value={value} >
<slot></slot>
</div>
App.svelte
<script>
import TextField from './TextField'
import {onMount} from 'svete'
onMount(() => {
// This line is funny.. I know
document.querySelector('[name="firstname"]').focus()
})
</script>
<TextField label="First Name" name="firstname" />
【问题讨论】:
-
我的问题有错别字。请参阅下面的答案以供参考。