added save and load json

This commit is contained in:
2023-02-06 19:11:19 +09:00
parent 1ef2570f45
commit 20a3a0bbe4
6 changed files with 235 additions and 19 deletions

View File

@@ -158,16 +158,36 @@
{/each}
</table>
<div class="save-load-clear-group">
<button>Save</button>
<button>Load</button><br />
<button
on:click={() => {
invoke("save_json", { jsonContent: pokemonDataArray})
.then(() => {})
.catch((err) => console.log(err));
}}
>
Save
</button>
<button
on:click={() => {
invoke("load_json").then((d) => {
pokemonDataArray = d;
pokemonData = pokemonDataArray[index];
})
.catch((e) => console.log(e));
}}
>
Load
</button><br />
<button
on:click={() => {
pokemonData = undefined;
pokemonDataArray = [];
index = 0;
myValue = undefined;
}}>Clear</button
}}
>
Clear
</button>
</div>
</div>
<div class="display-data">