[Vuejs]-Error while I am data:{} at nuxt js is it solvable?

0👍

Please try this code instead:

:type="totext ? ‘password’: ‘text’ "

<template>
    <div>
        <div id="login">
            <h1 style="font-size:30px; color:black;">Login</h1>
        <input type="text" placeholder="Username...">
        <input :type="totext ? 'password': 'text' " placeholder="Password...">
        <input type="checkbox" name="" id="" :checked="totext">
        <button class="button is-link">Submit</button>
        <a href="">Register</a>
        <a href="" class="repeat">Forgot the password..?!</a>
        </div>
    </div>
</template>

And this script:

<script>
export default {
  data () {
    return {
      totext : false
    }
  }
}
</script>

Or this one (the better one)

   <template>
        <div>
            <div id="login">
                <h1 style="font-size:30px; color:black;">Login</h1>
            <input type="text" placeholder="Username...">
            <input :type="isText" placeholder="Password...">
            <input type="checkbox" name="" id="" :checked="totext">
            <button class="button is-link">Submit</button>
            <a href="">Register</a>
            <a href="" class="repeat">Forgot the password..?!</a>
            </div>
        </div>
    </template>

And

<script>
export default {
  data () {
    return {
      totext : false
    }
  },
  computed: { 
      isText(){
         return totext ? 'password': 'text'
      }
  }
}
</script>

0👍

Please try this code :

 data: () => ({
inputtype: 'password'
)}

-1👍

You’ve merged the two sets of braces.

This:

data () {
  inputtype: 'password'
},

should be this:

data () {
  return {
    inputtype: 'password'
  }
},

Leave a comment