I am in the process of learning Vue. As far as I know I should be able to use a simple template string as a template in Vue. But for some reason, Vue renders only the first html tag.
Vue.config.devtools = true;
let template = `<h2>Hi {{name}}</h2><h1>{{age}}</h1>`
const vm = new Vue({
el: '#app',
data() {
return {
name: 'Name',
age: 23,
message: 'hello'
}
},
template,
methods: {
greet(e) {
return this.message = e.target.value
},
esc(e) {
e.target.value = ''
}
}
})
<div id="app"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
This renders only "Hi Name". Why isn't age showing up?
bodyelement, so you don't includehtml,head, orbodythere. I've updated the snippet to fix that. More about creating snippets: meta.stackoverflow.com/questions/358992