I have the following in my Messages.vue file:
<div class="msg" v-for="(msg, index) in messages" :key="index">
<p class="msg-index">[{{index}}]</p>
<p class="msg-subject" v-html="msg.subject"></p>
<p class="msg-body" v-html="msg.body"></p>
<input type="submit" @click="deleteMsg(msg.pk)" value="Delete" />
<input type="submit" @click="EditMsg(msg.pk)" value="Edit" />
</div>
<script>
export default {
name: "Messages",
data() {
return {
subject: "",
msgBody: "",
messages: [],
};
},
mounted() {
this.fetchMessages();
},
....
I want msg-subject and msg-body to change to input HTML elements, so the user can edit and submit them to be updated. I'm not really sure what's the best way to achieve this kind operation with VueJS.
<p>to have an<input>tag when when user click it or click another button? and the input to be stored so it can be sent through the form?htmltags? or edit without tags?