Skip to content

Instantly share code, notes, and snippets.

@dvallin
Created November 29, 2017 16:46
Show Gist options
  • Save dvallin/3ee3eaec3adfaea2912d21810a4dd7ed to your computer and use it in GitHub Desktop.
Save dvallin/3ee3eaec3adfaea2912d21810a4dd7ed to your computer and use it in GitHub Desktop.
<template>
<input class="new-todo"
autofocus autocomplete="off"
placeholder="What needs to be done?"
v-model="taskTitle"
@keyup.enter="addTask">
</template>
<script lang="ts">
import {Actions} from "../store/actions";
export default {
name: 'NewTaskInput',
data() {
return { taskTitle: "" }
},
methods: {
addTask() {
const value = this.taskTitle && this.taskTitle.trim();
this.$store.dispatch({
type: Actions.AddTask,
title: value
})
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment