问题
So I want to go through my array which ive crated on vue.js and then check against the arrary to decide where to save it. To explain it a bit more here's the code i have so far
Vue.js
var app= new Vue({
el: '.con',
data:{
posts: [
{
title:'',
content:'',
type:''
}
],
},
methods:{
addHead(index){
this.posts.push({
content:'',
type:'header',
})
},
addPara(index){
this.posts.push({
content:'',
type:'para',
})
},
removeForm(){
this.posts.splice(index, 1)
}
}
})
HTML
<div class="con">
<button type="button" name="button" @click='addHead()'>
header
</button>
<button type="button" name="button" @click='addPara()'>
Para
</button>
<input type="text" name="" placeholder="Title"
v-models='posts.title'>
<div id="body-fields">
<div class="car-body" v-for="(post, index) in posts">
<input type="textbox" name="" placeholder='{{post.type}}'
v-models='post.content'>
<span style="float:right;background-color:green"
@click='removeForm(index)'>
x
</span>
</div>
</div>
</div>
So i want to save the posts array depending on the type so if its a header save it to one model and if its the other type save it to another, i'm using python and django, thanks for any help
来源:https://stackoverflow.com/questions/60536343/vue-js-array-into-django