Reputation: 2691
I have sample code written in Vue:
template: `
<table>
<tbody>
<tr v-html="tableHTMLContent"></tr>
</tbody>
</table>`,
data() {
this.tableHTMLContent: '',
this.myTextName: 'aaaa'
},
methods: {
addSampleCode() {
this.tableHTMLContent = '<p> {{ myTextName }} </p>'
}
}
The problem is with parsing {{ myTextName }}
tag. Html is injected correctly, but Vue won't to parse myTextName variable. Vue doesn't display aaaa value.
What I have to do to parse Vue tags like {{ }} and others tags like v-for, v-if and so on.
Upvotes: 0
Views: 343
Reputation: 1104
To render data values together with template code within a method you can use Vue.compile( ... )
See this link:
https://v2.vuejs.org/v2/api/#Vue-compile
Usage Example:
var res = Vue.compile('<div><span>{{ msg }}</span></div>')
new Vue({
data: {
msg: 'hello'
},
render: res.render,
staticRenderFns: res.staticRenderFns
})
Upvotes: 3