3
3
const props = defineProps ([' questionId' ])
4
4
5
5
const addAnswer = ' addAnswer' ;
6
- const emit = defineEmits <{(e : typeof addAnswer , answer : IAnswer ): void }>()
6
+ const emit = defineEmits <{ (e : typeof addAnswer , answer : IAnswer ): void }>()
7
7
8
8
const questionId = props .questionId
9
9
@@ -15,38 +15,38 @@ const data: IAnswerPost = reactive({
15
15
const showAnswerForm = useState (' showAnswerForm' + questionId )
16
16
17
17
async function postAnswer() {
18
- const answer = await useFetch (
19
- () => ` /api/ask-jack/answer ` , { method: ' post' , body: { data } }
20
- );
18
+ const answer = await $fetch (` /api/ask-jack/answer ` , { method: ' post' , body: { data } });
21
19
22
20
const newAnswer = useState (' newAnswer' )
23
- newAnswer .value = answer . data . value
21
+ newAnswer .value = answer
24
22
25
- emit (' addAnswer' , newAnswer . value as IAnswer )
23
+ emit (' addAnswer' , answer )
26
24
27
25
data .text = ' '
26
+ console .log (' &&&&&&&&& end post answer' )
28
27
}
28
+
29
29
</script >
30
30
31
31
32
32
<template >
33
- <form @submit.preventDefault =" postAnswer" >
34
- <label for =" message" class =" block mb-2 text-sm font-medium text-gray-900 dark:text-gray-400" >Answer</label >
35
- <textarea v-model =" data.text" id =" message" rows =" 4"
36
- class =" block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 focus:ring-indigo-500 focus:border-indigo-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-indigo-500 dark:focus:border-indigo-500"
37
- placeholder =" Be specific and kind" >
33
+ <form @submit.preventDefault =" postAnswer" >
34
+ <label for =" message" class =" block mb-2 text-sm font-medium text-gray-900 dark:text-gray-400" >Answer</label >
35
+ <textarea v-model =" data.text" id =" message" rows =" 4"
36
+ class =" block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 focus:ring-indigo-500 focus:border-indigo-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-indigo-500 dark:focus:border-indigo-500"
37
+ placeholder =" Be specific and kind" >
38
38
</textarea >
39
- <div >
40
- </div >
41
- <div class =" flex justify-end" >
42
- <button @click =" postAnswer" type =" button"
39
+ <div >
40
+ </div >
41
+ <div class =" flex justify-end" >
42
+ <button @click =" postAnswer" type =" button"
43
43
class =" mt-5 px-6 py-3.5 text-white bg-gradient-to-r from-indigo-500 via-indigo-600 to-indigo-700 hover:bg-gradient-to-br focus:ring-4 focus:outline-none focus:ring-indigo-300 dark:focus:ring-indigo-800 font-medium rounded-lg text-sm px-5 py-2.5 text-center mr-2 mb-2" >
44
44
Submit
45
45
</button >
46
46
<button @click =" showAnswerForm = !showAnswerForm" type =" button"
47
47
class =" mt-5 px-6 py-3.5 text-white bg-gradient-to-r from-red-500 via-red-600 to-red-700 hover:bg-gradient-to-br focus:ring-4 focus:outline-none focus:ring-indigo-300 dark:focus:ring-indigo-800 font-medium rounded-lg text-sm px-5 py-2.5 text-center mr-2 mb-2" >
48
48
Cancel
49
49
</button >
50
- </div >
51
- </form >
50
+ </div >
51
+ </form >
52
52
</template >
0 commit comments