码迷,mamicode.com
首页 > 其他好文 > 详细

vue父组件中获取子组件中的数据

时间:2017-09-26 17:49:44      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:nes   vue   img   获取   好的   图片   color   class   for   

<FormItem label="上传头像" prop="image">
                    <uploadImg :width="150" :height="150" :name="‘avatar‘" size="150px*150px" ref="avatar"></uploadImg>
</FormItem>
 <FormItem label="上传营业执照" prop="businessLicence">
       <uploadImg :width="350" :height="200" :name="‘businessLicence‘" size="350px*200px" ref="businessLicence"></uploadImg>
</FormItem>

自己写了个上传图片的子组件,父组件需要获取到子组件上传的图片地址,这里最好的办法是给相应的子组件加ref,

父组件在最后提交的时候获取thi.$ref.avatar.相应数据即可,因为在这里才能保证图片已经上传,否则如果图片没上传,拿到的值一定为空。

vue父组件中获取子组件中的数据

标签:nes   vue   img   获取   好的   图片   color   class   for   

原文地址:http://www.cnblogs.com/beileixinqing/p/7597647.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!