<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>todolist</title>
<script src="vue.js"></script>
</head>
<body>
<div id="root">
<div>
<input v-model="inputValue"/>
<button disabled="loginId" v-on:click="handleClick">Enter</button>
</div>
<ul>
<li v-for="(item,index) of list":key="index">
{{item}}
</li>
</ul>
</div>
<script>
new Vue({
el: '#root',
data:{
inputValue:'',
list:[]
},
methods:{
handleClick:function(){
this.list.push(this.inputValue)
inputValue=''
}
},
computed: {
isLogin() {
return !!inputValue
}
}
})
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>todolist</title>
<script src="vue.js"></script>
</head>
<body>
<div id="root">
<div>
<input v-model="inputValue"/>
<button :disabled="!inputValue" v-on:click="handleClick">Enter</button>
</div>
<ul>
<li v-for="(item,index) of list" :key="index">
{{item}}
</li>
</ul>
</div>
<script>
new Vue({
el: '#root',
data:{
inputValue:'',
list:[]
},
methods:{
handleClick:function(){
this.list.push(this.inputValue)
inputValue=''
}
}
});
</script>
</body>
</html>
<!DOCTYPE html><html><head> <meta charset="UTF-8"> <title>todolist</title> <script src="vue.js"></script></head><body><div id="root"> <div> <input v-model="inputValue"/> <button :disabled="!inputValue" v-on:click="handleClick">Enter</button> </div> <ul> <li v-for="(item,index) of list" :key="index"> {{item}} </li> </ul></div><script> new Vue({ el: '#root', data:{ inputValue:'', list:[] }, methods:{ handleClick:function(){ this.list.push(this.inputValue) inputValue='' } } });</script></body></html>
没用computed,这样就可以了.