不能预览图片
来源:6-10 个人设置页面上传头像功能实现

spider18
2018-03-29
js文件改了,还是报错 Uncaught TypeError: Cannot set property 'uploadImgUrl' of undefined
js脚本,按照视频修改好了,还是报错
var editor = new wangEditor('content');
if (editor.config){
editor.config.uploadImgUrl = "/posts/image/upload";
// 设置 headers(举例)
editor.config.uploadHeaders = {'X-CSRF-TOKEN' : $('meta[name="csrf-token"]').attr('content')};
editor.create();
};
$(".preview_input").change(function(event){
var file = event.currentTarget.files[0];
var url = window.URL.createObjectURL(file);
$(event.target).next(".preview_img").attr("src",url);
});
blade修改
<div class="form-group">
<label class="col-sm-2 control-label">头像</label>
<div class="col-sm-2">
<input class="file-loading preview_input" type="file" value="用户名" style="width:220px" name="avatar">
<img class="preview_img" src="{{$user->avatar}}" alt="" class="img-rounded" style="border-radius:500px;">
</div>
</div>
<button type="submit" class="btn btn-default">修改</button>
3回答
-
BakerYoung
2018-06-07
同学,请确认下 你改的js文件是否在public/js/目录下的?
00 -
51change_世界
2018-05-07
同学,能不能请教一下你这个问题是怎么解决的呀
00 -
轩脉刃
2018-04-02
你确定有id为content 的标签么
022018-05-10
相似问题