Vue Data Binding HTML

Source: Internet
Author: User

Plain text display of HTML tags/treated as HTML tags;

1) When using two curly braces, if the string content is HTML tag, then it will not be escaped;

2) When using three curly braces, the HTML tags inside the string are escaped directly

A. Two curly braces:

1 <DivID= "App">  2 {{html}}3 </Div>  4 <Script>  5     varVMS= NewVue ({6 el:"#app",  7 data: {8 HTML:"<span>span</span>"  9         }  Ten     })   One </Script>  

Output Result:

1 < span >span</span>  

B. Three curly braces:

1 <DivID= "App">  2 {{{html} }}3 </Div>  4 <Script>  5     varVMS= NewVue ({6 el:"#app",  7 data: {8 HTML:"<span>span</span>"  9         }  Ten     })   One </Script>   A <Script>   -     functionload () { - VMs. $mount ("#app");  the     }   - </Script>  

Output:

1 Span

3) Invalid data binding for inserted content (in case of No partials), two curly braces, three curly braces

1 <DivID= "App">  2 {{{html} }}3 </Div>  4 <Script>  5     varVMS= NewVue ({6 el:"#app",  7 data: {8 HTML:"<span>span{{val}}</span>",  9 Val:" One"    Ten         }   One     })   A </Script>   - <Script>   -     functionload () { the VMs. $mount ("#app");  -     }   - </Script>          

Output:

Span{{val}}

Description no data binding.

4) Prohibit dynamic rendering on user-submitted content, or be subject to XSS attacks

5) interpolation can also be used in attributes of HTML tags, such as class, or ID, or other.

However, it is not possible to use interpolation in the instruction and particularity of Vue.js.

Vue Data Binding HTML

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.