所以我想将data(object)作为prop传递给不同的组件。我的目标是使表组件可重用。
App.svelte
<script>
import {onMount} from 'svelte';
import Tabel from './components/Tabel.svelte';
let data = [];
onMount(async () => {
try {
let res = await fetch(url); // your url
data = await res.json();
} catch(err){
throw err;
}
})
</script>
<Tabel {data} />
Table.svelte
<script>
export let data = [];
</script>
<table class="table-auto">
<thead>
<tr>
<th class="px-4 py-2">Name</th>
<th class="px-4 py-2">Age</th>
<!-- and so on -->
</tr>
</thead>
<tbody>
{#each data as {name, age}, i}
<tr>
<th class="px-4 py-2">{name}</th>
<th class="px-4 py-2">{age}</th>
<!-- and so on -->
</tr>
{/each}
</tbody>
</table>
但是我有这样的错误:
rollup v2.16.1
bundles src/main.js → public/build/bundle.js...
[!] Error: Could not resolve './components/Tabel.svelte' from src/App.svelte
Error: Could not resolve './components/Tabel.svelte' from src/App.svelte
答案 0 :(得分:1)
您有错字。导入Table的专有名称:
for name in namelist:
closematch = difflib.get_close_matches(name, banklist, 1, 0.8)
closematchlist = list()
closematchlist.append(closematch)
print(closematch)
print(closematchlist)```