Answer the question
In order to leave comments, you need to log in
Vue.js: why is the document not being generated?
For a fraction of a second, the document is generated and disappears. This is clearly related to the v-else-if directive
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Vue</title>
</head>
<body>
<div id="app">
<h2 v-if="letter==='a'">a</h2>
<h2 v-else-if="letter==='b'">b</h2>
<h2 v-else-if="letter===='c'">c</h2>
<h2 v-else>not match</h2>
<hr>
<input type="text" v-model="someinput">
<h2>{{mes}}</h2>
</div>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.min.js"></script>
<script type="text/javascript">
new Vue ({
el: '#app',
data: {
someinput:'a',
mes:'Hy there'
}
})
</script>
</body>
</html>
Answer the question
In order to leave comments, you need to log in
Syntax error: extra 4th equal sign for "c".
And, most importantly, the variable letter
was not defined.
It is necessary to make both the model and the variable v-if
the same:
new Vue ({
el: '#app',
data: {
someinput:'a',
mes:'Hy there',
letter: 'a'
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question