小编Dor*_*ian的帖子

使用 Svelte 逐行写入文本文件的内容

我在 svelte 中编写了这段代码,打开一个 txt 文件,并将其写入 html 段落。这是代码:

<input type='file' multiple bind:files'>

{#if files}
    <h2>Files selected: </h2>
{#each Array.from(files) as file}
<p> IThe imported file is: {file.name}</p>
{#await file.text() then text}
<p>{text}</p>
{/await}
{/each}
{/if}
Run Code Online (Sandbox Code Playgroud)

示例文件如下:

beans
spam
donut
Run Code Online (Sandbox Code Playgroud)

但它给了我这个:

beans spam donut
Run Code Online (Sandbox Code Playgroud)

如何<br>为文本中的每一行创建一个新行(段落或 )?

svelte

3
推荐指数
1
解决办法
1811
查看次数

标签 统计

svelte ×1