想問一個簡單程序的問題
<button type="button" @click="count += 1"> Submit {{count}}</button>
這段代碼中的“?Submit {{count}}”的“{{count}}”部分在編譯后為什么不能正常顯示為0,是哪里沒有連接上嗎?
代碼如下:
<!DOCTYPE html>??
<html>??
??
? ? <head>??
? ? ? ? <meta charset="text/html;charset=utf-8">??
? ? ? ? <title>Vue js</title>??
? ? ? ? <script src="https://unpkg.com/vue"></script>
? ? ? ? <link rel="stylesheet" href="main.css">
? ? </head>??
??
? ? <body>
? ? <div id="app">
? ? ? ? <button type="button" @click="count += 1"> Submit {{count}}</button>? ? //這里是重點
? ? ? ? </div>
? ? ? ? <script>??
? ? ? ? ??
? ? ? ? ? new Vue({
? ? ? ? ? el:'#app',
? ? ? ? ? data:{
? ? ? ? ? count:0
? ? ? ? ? },
? ? ? ? ? methods:{
? ? ? ? ? updataCount:function(){
? ? ? ? ? this.count ++ 1;
? ? ? ? ? }
? ? ? ? ? }
? ? ? ? ? })
? ? ? ? </script>??
? ? </body>??
??
</html>
2018-11-02
@click后面直接跟方法即可
2018-10-27
名字不對
2018-10-27
count:“0”