给button添加 v-on:click 为什么报错?

poi_rs
  • 478
<template>
    <form class="form signup">
        <h2>注册新用户</h2>
        <input v-model="signupUsername" type="username" id="inputUsername" class="form-control" placeholder="username" required autofocus>
        <input v-model="signupPassword" type="password" id="inputPassword" class="form-control" placeholder="Password" required>
        <input v-model="emailAddress" type="email" id="inputEmail" class="form-control" placeholder="Email address" required>
// 下面的button添加了 v-on:click="pushMessage"
        <button v-on:click="pushMessage" type="submit">注册</button>
    </form>
</template>
<script>
    export default {
        name: 'Signup',
        data() {
            return {
                signupUsername: '',
                signupPassword: '',
                emailAddress: 'sdfas'
            }
        },
// pushMessage方法在这里
        method: {
            pushMessage: function() {
                console.log('123')
                
            }
        }
    }
</script>

结果报错
clipboard.png

感觉有点莫名奇妙?语法也应该没有出现问题?

回复
阅读 3k
2 个回答
✓ 已被采纳

methods

宣传栏