如何解决我是数据时出错:{}在nuxt js上可以解决吗?
这是我想输入密码并选中复选框的模板,我想在内部输入中输入文字以代替密码
<!--template-->
<template>
<div>
<div id="login">
<h1 style="font-size:30px; color:black;">Login</h1>
<input type="text" placeholder="Username...">
<input :type="inputtype" 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>
17:5 error Unexpected labeled statement no-labels
17:16错误预期分配或函数调用,而是看到一个表达式
<script>
export default {
data () {
inputtype: 'password'
},methods: {
totext () {
this.inputtype = this.inputtype === 'password' ? 'text' : 'password'
}
}
}
</script>
解决方法
请尝试以下代码:
data: () => ({
inputtype: 'password'
)}
,
请改用以下代码:
:type =“ totext?'密码':'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>
这个脚本:
<script>
export default {
data () {
return {
totext : false
}
}
}
</script>
或这个(更好的一个)
<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>
和
<script>
export default {
data () {
return {
totext : false
}
},computed: {
isText(){
return totext ? 'password': 'text'
}
}
}
</script>
,
您已经合并了两组大括号。
此:
data () {
inputtype: 'password'
},
应该是这样:
data () {
return {
inputtype: 'password'
}
},
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。