请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

正在回答 回答被采纳积分+3

2回答

提问者 前端侠 2018-08-27 23:02:00
return {
    userForm: {
    name:'',
    username: '',
    gender: '',
    birthday: '',
    email: '',
    mobile: '',
    image:''
    },
}
handleAvatarSuccess(res, file) {
    //this.imageUrl = URL.createObjectURL(file.raw);
    this.userForm.image = URL.createObjectURL(file.raw);
    console.log(this.imageUrl);
},
confirmModify () { // 确认修改
    var that = this;
    updateUserInfo(that.userForm).then((response)=> {
    that.saveInfoAjax();
    }).catch(function (error) {
    console.log(error);
    });
},

vue代码如上

0 回复 有任何疑惑可以回复我~
  • bobby #1
    你这个代码逻辑是运行要出错还是什么?
    回复 有任何疑惑可以回复我~ 2018-08-29 11:17:31
  • 提问者 前端侠 回复 bobby #2
    出错,image : ["提交的数据不是一个文件。请检查表单的编码类型。"]
    回复 有任何疑惑可以回复我~ 2018-08-29 11:23:58
  • 提问者 前端侠 回复 bobby #3
    这个问题困扰了很久,查了很多文章,没说到具体原因是什么,请问老师可以加下qq,帮我调试下吗?
    回复 有任何疑惑可以回复我~ 2018-08-29 11:25:35
bobby 2018-08-21 18:26:03

这个需要自己去写css和js逻辑了 https://element.eleme.io/#/zh-CN/component/upload 你可以看看这个组件里面有头像上传

0 回复 有任何疑惑可以回复我~
  • 提问者 前端侠 #1
    一直报这个错,是不是后台django的imagefiled没用对?image : ["提交的数据不是一个文件。请检查表单的编码类型。"]
    回复 有任何疑惑可以回复我~ 2018-08-21 20:42:41
  • bobby 回复 提问者 前端侠 #2
    你提交的数据文件不对 你是如何提交文件的?
    回复 有任何疑惑可以回复我~ 2018-08-23 10:23:11
  • 提问者 前端侠 回复 bobby #3
    userForm: {
                    name:'',
                    username: '',
                    gender: '',
                    birthday: '',
                    email: '',
                    mobile: '',
                    image:''
                },
    handleAvatarSuccess(res, file) {
            this.userForm.image = URL.createObjectURL(file.raw);
          },
    之后就是updateuserinfo函数了:
    updateUserInfo(that.userForm).then((response)=> {
                    //
                })
    回复 有任何疑惑可以回复我~ 2018-08-23 23:10:42
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信