Vue.js 2.x version script the DOM is filtered to get a solution that does not have a DOM string

Source: Internet
Author: User

In the project Vue.js in the 1.x version of the switch to the 2.x version of the problem is that when the 1.x version is instantiated, the DOM string inside the script will not be filtered out, but the 2.x version will be filtered for example:

Script content after the 1.x version is instantiated

Script content after the 2.x version is instantiated

So we can't get to the DOM structure when we get id= "sh" content, and many times we want to use these DOM constructs.

So, after a test and a document review, if you haven't been fully instantiated yet, then we're going to get it so we can get the DOM that hasn't been filtered yet?

Yes created method, so the following code has been completed.

<!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <title>Document</title></Head><Body><Divclass= "App">        <Scripttype= "Text/x-template"ID= "sh">        <Div>            <H1>1111</h1>            <P>{{msg}}</p>        </div>    </Script>    <Button@click= "SetData">Audit</Button></Div><Scriptsrc= "Jquery.min.js"></Script><Scriptsrc= "Vue.min.2.x.js"></Script><Script>        NewVue ({el:'. App', Data: {msg:NULL, shhtml:NULL}, created:function(){             This. GETSCRIPTDOMSTR (); }, methods: {getscriptdomstr:function(){                 This. shhtml=document.getElementById ('SH'). InnerHTML}, SetData:function(){                $('. App'). Append ('<div id= "TPL" ></div>')                var_self=  This; NewVue ({el:'#tpl', Data: {msg: $}, Template: _self.shhtml}) }})</Script></Body></HTML>

Vue.js 2.x version script the DOM is filtered to get a solution that does not have a DOM string

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.