-
글쓴이글
-
2022년 8월 31일 16:50 #44788
유용환참가자methods : {
userTitle(e){ // db.collection('user_post').add({title: e.target.value}) this.$store.state.user_title = e.target.value },
userContent(e){ // db.collection('user_post').add({content : e.target.value}) this.$store.state.user_content = e.target.value },
more(){ db.collection('user_post').add({title : this.$store.state.user_title , content : this.$store.state.user_content}) console.log(this.$store.state.user_title, this.$store.state.user_content) } } 위의 상태에서 유저가 글을 올렸을때 파이어베이스에서 아무것도 안올라와서 more함수에 콘솔로 확인해보면 잘 나옵니다. 주석달린것을 해제하면 파이어베이스에 올라오기는 하는데 3개가 따로 올라옵니다. title, content, 이 두개 모두 합친것 이렇게 나오는데 more함수에서만 해당되는것이 파이어베이스에 올려지도록 하고싶은데 어떻게 해야하나요
2022년 9월 1일 11:08 #44879
유용환참가자사용자가 입력한 값을 가져와야 해서 함수를 사용하고 각각 함수마다 콘솔로 this.$store.state.user_title, this.$store.state.user_content 을 출력해보면 잘 나오고 more함수에서 콘솔로 this.$store.state.user_title , this.$store.state.user_content 을 출력하면 잘나오는데 이상하게 파이어베이스 데이터베이스에는 안올라오네요 이거 왜 그런건가요
2022년 9월 1일 19:13 #44981
유용환참가자<fieldset> <input placeholder="글 제목" type="text" tabindex="1" @change="userTitle" required autofocus> </fieldset> <fieldset> <textarea placeholder="글 내용" tabindex="5" @change="userContent" required></textarea> </fieldset> <button name="submit" type="submit" id="contact-submit" @click="more">Submit</button> 이 상태에서 글 제목과 글 내용에 해당하는 것들을 변수에 저장해 놓고 그 변수안에 있는것을 클릭했을때 파이어베이스 데이터 베이스 에 저장하려고 한건데 안됩니다. 위의 주석한 부분을 해제하고 실행하면 각각 함수가 실행되어서 3개가 데이터베이스에 저장되고 다시 그 부분들을 주석처리하면 클릭했을때 아무것도 안나옵니다.
2022년 9월 1일 19:56 #44986
codingapple키 마스터@change 할 때 마다 data란에 유저가 입력한거저장해두고 전송버튼 누르면 data 가져와서 파이어베이스에 저장하라고 코드짭시다 vue에선 폼전송말고 보통 ajax 요청으로 통신하면 됩니다
2022년 9월 2일 19:05 #45121
유용환참가자more함수에 more(){ axios.post(url', {title : this.$store.state.user_title, contents : this.$store.state.user_content}) } 이렇게 했는데 파이어베이스 url검색해보니까 realtime database를 만들면 제 서버의 url이 나오는데 그곳을 url 자리에다 붙여놓고 실행시키면 오류는 안나오고 콘솔로 출력해보면 두개 모두 잘나오는데 realtime database과 firestoredatabase에도 안생기는데 어떻게 해야하나요
-
글쓴이글
- 답변은 로그인 후 가능합니다.