带有 contenteditable 属性的元素支持 textContent 和 innerHTML 绑定:
App
<div bind:innerHTML={html} contenteditable></div>上一页 下一页
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<script>
let html = $state('<p>Write some text!</p>');</script>
<div contenteditable></div>
<pre>{html}</pre><style>
[contenteditable] {padding: 0.5em;
border: 1px solid #eee;
border-radius: 4px;
}
</style>