Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9beb162

Browse files
emit text input value up to parent
1 parent 9a5255c commit 9beb162

File tree

3 files changed

+32
-10
lines changed

3 files changed

+32
-10
lines changed

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"axios": "^0.19.2",
1212
"bootstrap-vue": "^2.10.1",
1313
"core-js": "^3.6.4",
14+
"uuid": "^8.0.0",
1415
"vue": "^2.6.11",
1516
"vue-router": "^3.1.6",
1617
"vue2-editor": "^2.10.2"

‎src/components/TextInput.vue‎

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,35 @@
11
<template>
22
<div>
3-
<b-form-input v-model="text" placeholder="Ingrese una nota"></b-form-input>
3+
<b-form v-on:submit.prevent="addNote">
4+
<b-form-input
5+
type="text"
6+
v-model="text"
7+
placeholder="Ingrese una nota"
8+
></b-form-input>
9+
</b-form>
410
</div>
511
</template>
612

713
<script>
8-
export default {
9-
props: {
10-
text: String
11-
// },
12-
// data() {
13-
// return {
14-
// text: ''
15-
// }
14+
import {v4 as uuidv4} from "uuid";
15+
16+
export default {
17+
data() {
18+
return {
19+
text: ""
20+
};
21+
},
22+
methods: {
23+
addNote() {
24+
const newNote = {
25+
id: uuidv4(),
26+
text: this.text,
27+
complete: false
28+
};
29+
30+
// send up to parent
31+
this.$emit("add-note", newNote);
1632
}
1733
}
34+
};
1835
</script>

‎src/views/Home.vue‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
<template>
22
<div class="col-12">
33
<h3 class="m-2">{{title}}</h3>
4+
<TextInput/>
45
<List />
56
</div>
67
</template>
78

89
<script>
9-
import List from "@/components/List"
10+
import TextInput from '@/components/TextInput.vue';
11+
import List from "@/components/List";
12+
1013
export default {
1114
name: 'Home',
1215
data() {
@@ -15,6 +18,7 @@ export default {
1518
}
1619
},
1720
components: {
21+
TextInput,
1822
List
1923
}
2024
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /