javascript - How can i bind string return from ajax call with v-html in v-for in vue.js? -


i want bind v-html string returning ajax call in v-for.

<div v-for="row in data">   <div v-html="gethtml[row.id]"></div> 

//fun gethtml(i){  this.$http.get('.....').then((data) => return data.html;) } 

it this:

@template

<div id="app">     <div v-html="newcontent"></div> </div> 

@vue instance

var vm = new vue({     el: "#app"     data: {         newcontent: ''     },     mounted: function() {         var = this;         this.$http.get(endpoint)             .then(function(data) { that.newcontent = data })             .catch(function(error) { console.log(error); });     } }); 

what happening?

at example binding data property newcontent div using v-html directive. means everytime property changes div content updated.

after component gets mounted fire ajax request .then() assign response data newcontent property, seen before automatically update view due reactivity.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -