Use v-html to resolve HTML tags that cannot be parsed during Vue.js rendering (HTML tags appear as strings)

Source: Internet
Author: User

Original address: http://blog.csdn.net/faryang/article/details/53011703

In a Web page, the JSON data in the background contains the HTML tag, binds the JSON data to the object in Vue.js, and makes a for loop of the object, discovering that the HTML tags in the data cannot be parsed, but are displayed as characters. The problem is as follows:



Solve:

The v-html directive is provided in vue.js to solve this problem, or the data object can be parsed correctly by using the {{{vm.data}}} three braces to wrap the object. The code changes are as follows:


In some cases, using the {{}}} symbol still fails to parse the HTML tag, but the v-htm directive can, possibly, be a vue.js bug. Explain the figure below


Resources:

Vue.js official Website API----http://vuejs.org.cn/api/#v-html

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.