8000 Clarify v-html usage (#905) · tinymachine/vuejs.org@84a65b1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 84a65b1

Browse files
lloy0076chrisvfritz
authored andcommitted
Clarify v-html usage (vuejs#905)
* Update syntax.md Originally, I'd thought that: ``` <div v-html="rawHtml">This {{ some_html}}</div> ``` (where we might have `vm.data.some_html='<b>hello</b>'`) ... would render something like: **hello** But instead we get: ``` Property or method "rawHtml" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option. ``` ...if one is watching console errors. My wording could be a little bit kludgy and others might be able to make it clearer but I think this may overcome some misunderstandings for those not familiar with vuejs. * Update syntax.md
1 parent 382b8ac commit 84a65b1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/v2/guide/syntax.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ The double mustaches interprets the data as plain text, not HTML. In order to ou
3636
<div v-html="rawHtml"></div>
3737
```
3838

39-
The contents are inserted as plain HTML - data bindings are ignored. Note that 50C4 you cannot use `v-html` to compose template partials, because Vue is not a string-based templating engine. Instead, components are preferred as the fundamental unit for UI reuse and composition.
39+
The contents of this `div` will be replaced with the value of the `rawHtml` property, interpreted as plain HTML - data bindings are ignored. Note that you cannot use `v-html` to compose template partials, because Vue is not a string-based templating engine. Instead, components are preferred as the fundamental unit for UI reuse and composition.
4040

4141
<p class="tip">Dynamically rendering arbitrary HTML on your website can be very dangerous because it can easily lead to [XSS vulnerabilities](https://en.wikipedia.org/wiki/Cross-site_scripting). Only use HTML interpolation on trusted content and **never** on user-provided content.</p>
4242

0 commit comments

Comments
 (0)
0