Created
June 23, 2022 05:56
-
-
Save sardinecan/390e19604d436033a8817eaacd0e004b to your computer and use it in GitHub Desktop.
HTML from JSON 2 HTML with Svelte Kit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
import { onMount } from 'svelte' ; | |
let container; | |
let str = { | |
"foo": "<h1>Hello World</h1><p>Hello World in a paragraph</p>" | |
}; | |
onMount(() => { | |
let newInnerHTML = str.foo | |
container.innerHTML = newInnerHTML; | |
}); | |
function makeStrong() { | |
let newInnerHTML = str.foo; | |
container.innerHTML = newInnerHTML; | |
} | |
</script> | |
<div bind:this={container}/> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment