#やりたいこと
propsの値をdataに渡したいのですが、うまくいきません。
data(){ returun{ uploaded_image: this.prop_uploaded_image } }
上記で取得できると思うのですが、uploade_imageに入らないのが現状です。
#ソース
js
1//親コンポーネント 2<template> 3 <div> 4 <router-view 5 :su_company.sync="su_company" 6 :capital_units.sync="capital_units" 7 :investment_rounds.sync="investment_rounds" 8 :stages.sync="stages" 9 :prefectures.sync="prefectures" 10 :industries.sync="industries" 11 :prop_uploaded_image.sync="prop_uploaded_image" <- これを渡す 12 :prop_img_name.sync="prop_img_name" 13 :password.sync="password" 14 :password_confirm.sync="password_confirm" 15 > 16 </router-view> 17 </div> 18</template> 19 20<script> 21 export default { 22 data() { 23 return { 24 su_company: {}, 25 capital_units: {}, 26 investment_rounds:{}, 27 stages:{}, 28 prefectures: {}, 29 industries: {}, 30 prop_uploaded_image: '', 31 prop_img_name: '', 32 password: '', 33 password_confirm: '', 34 } 35 }, 36 beforeMount() { 37 if(this.$route.name !== "SuSuEditConfirm"){ 38 this.fetchSuCompany(); 39 this.$store.commit('su_company/initPassword'); 40 }else{ 41 this.getPassword; 42 this.getPasswordConfirm; 43 } 44 this.fetchRelatedParts(); 45 }, 46 methods: { 47 fetchSuCompany: function() { 48 this.$auth.api.get(`/su/su_companies/edit`) 49 .then(response => { 50 this.su_company = response.data.su_company 51 this.prop_upload_image = this.su_company.image_url <- ここでつめてる 52 }); 53 }, 54 fetchRelatedParts: function() { 55 this.$auth.api.get(`/su/su_companies/related_parts`) 56 .then(response => { 57 this.capital_units = response.data.capital_units 58 this.investment_rounds = response.data.investment_rounds 59 this.stages = response.data.stages 60 this.prefectures = response.data.prefectures 61 this.industries = response.data.industries 62 }); 63 }, 64 }, 65 computed: { 66 getSuCompany () { 67 this.su_company = this.$store.getters['su_company/suCompany'] 68 }, 69 getPassword () { 70 this.password = this.$store.getters['su_company/password'] 71 }, 72 getPasswordConfirm () { 73 this.password_confirm = this.$store.getters['su_company/passwordConfirm'] 74 }, 75 getUploadedImage () { 76 this.prop_uploaded_image = this.$store.getters['su_company/uploadedImage'] 77 }, 78 getImgName () { 79 this.prop_img_name = this.$store.getters['su_company/imgName'] 80 } 81 }, 82 created: function(){ 83 this.getSuCompany; 84 this.getImgName; 85 this.getUploadedImage; 86 } 87 } 88</script>
js
1//子コンポーネント 2 export default { 3 props: { 4 su_company: Object, 5 capital_units: Object, 6 investment_rounds: Object, 7 stages: Object, 8 prefectures: Object, 9 industries: Object, 10 prop_uploaded_image: String, <- ここで受け取る 11 prop_img_name: String, 12 password: String, 13 password_confirm: String, 14 }, 15 data() { 16 return { 17 uploaded_image: this.prop_uploaded_image, <- ここで詰める 18 img_name: this.prop_img_name, 19 days_max: '', 20 errors: '', 21 reserve_password: this.password, 22 reserve_password_confirm: this.password_confirm, 23 // img_src: require(this.su_company.image_url), 24 toggle_password: 'password', 25 toggle_password_confirm: 'password', 26 } 27 },
#上記ソースの結果
propsにはちゃんといるが、data側には値がはいっていません。。
原因がわからず困っています。
ご回答お待ちしております。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/12/13 11:51