これは私のHTMLコードです。ここで
contenteditable div HTML要素を追加し、それをVuejsでモデル化します
<div id="app">
<button @click="renderHtml">clisdfsdfsdfck to appen html</button>
<div class="flex">
<div class="message" @input="fakeVmodel" v-html="html" contenteditable="true"></div>
<div class="message">{{ html }}</div>
</div>
</div>
jsの一部である
let app = new Vue({
el: '#app',
data: {
html: 'some text',
},
methods: {
fakeVmodel: function(e){
this.html = e.target.innerText;
},
renderHtml: function(){
this.html += '<img src="https://cdn-images-1.medium.com/max/853/1*FH12a2fX61aHOn39pff9vA.jpeg" alt="" width=200px>';
}
}
});
問題は、私は私の変数(HTML)にhtmlタグ(IMG)をプッシュするボタンをクリックして、それが動作するとき、です。入力後、挿入されたタグ部分は削除されます。 Vueで成功したhtmlコードを追加する方法はありますか?ここで
主な問題codepen例 https://codepen.io/weretyc/pen/EwXZYL?editors=1010
おかげで多くのことを。 – Fan