简体   繁体   中英

Blank White Page in Vue.js with input null

I am having problems with vue.js. I want to show a piece of text if the input is null. Everything just shows up as a blank white page when I run my HTML page.

HTML:

    <!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vue.js Testing</title>
</head>

<body>
   <template>
    <div id="input">
        <span v-if="{{ input1 }} == null"> Empty </span>
        <p>{{ input1 }}</p>
        <input v-model="input1">
    </div>
   </template>

    <script src="vue.js"></script>
    <script src="scripts.js"></script>
</body>

</html>

And my JS:

var input = new Vue({
    el: '#input',
    data: {
      input1: 'Default'
    },
  })

Thanks for the help!

it should be like this:

<div id="input">
        <span v-if="!input1"> Empty </span>

        <p>{{ input1 }}</p>
        <input v-model="input1">
    </div>

This is because you are using curly bois inside of a v-if, No curly bois required.

    <div id="input">
        <span v-if="!input">Empty</span>
        {{ input }}
        <input v-model="input">
    </div>

https://codepen.io/michaelmano/pen/zYNmbjb

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM