功能无法识别

时间:2019-12-24 19:15:41

标签: vuejs2

我已使用默认的Vue模板创建待办事项应用程序。我正在将输入与功能连接。当我更改输入值时,我希望文本在控制台上记录。目前无法识别submitTodo()

<template>
  <div class="hello">
    <h1>{{ msg }}</h1>
    <input @keydown.enter="submitTodo" type="text" name="todo" placeholder="Todo">
  </div>
</template>

<script>
export default {
  name: 'HelloWorld',
  props: {
    msg: String
  },
  method:{
    submitTodo()
    {
      console.log("clicked")
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>

1 个答案:

答案 0 :(得分:0)

您的VueJS组件中有一个错字。它应该是methods(复数)。