设置div的contenteditable属性为true可以模仿富文本
<div class="text" contenteditable="true"></div> <input @change="chooseImg" type="file" accept="image/*" />
chooseImg(e) { var reader = new FileReader(); reader.onload = function(e) { const str = "<img style='width:100%' src='" + e.target.result + "'><br /><br />"; let ele = document.querySelector(".text"); ele.innerHTML = ele.innerHTML + str; }; reader.readAsDataURL(e.target.files[0]); }