在我的VUE应用程序中,我试图发送一个名为c(c代表颜色)的变量。出于某种原因,我的http post请求中的所有其他变量都正在正确发送,但是对于this.c,发送的值始终为空。这是奇怪的,因为我在函数的上下文中打印this.c的值我从this.c的值发出请求是正确的(因为它是用户输入select标签的相同值) 。然而,即使我在发布帖子时值是正确的,color1属性的值也始终为空。 (同样,帖子中的所有其他属性都可以很好地连接到服务器,除了color1)
以下是相关代码:
<template>
<div id="calendar" :navL="navLinks" :event-sources="eventSources" @event-selected="eventSelected" @event-created="eventCreated" :config="config" >
<div class="container" id="calendarContainer">
<div id="end">
<div class="col-2">
<select v-model="c">
<option value="#07889B">Blue</option>
<option value="#F9CF00">Yellow</option>
</select>
</div>
</div>
</div>
<full-calendar id="target" ref="calendar" :event-sources="eventSources" @event-selected="eventSelected" @day-click="click"@event-created="eventCreated" :config="config"></full-calendar>
</div>
</template>
<script>
import moment from 'moment';
const self = this;
export default {
name: 'calendar',
data() {
return {
//there are other variables in here of course
c: "color", //************ this variable wont get sent in post request
};
},
methods: {
submit: function() {
console.log(this.c); //*****************
this.$http.post('http://localhost:3000/operation?Stime='+this.Stime+'&Etime='+this.Etime+'&eAMPM='+this.eAMPM+'&sAMPM='+this.sAMPM+'&id='+this.id+'&activity='+this.activity+'&auto_insert='+this.auto_insert+'&yearmonthday='+this.yearmonthday+'&color1='+this.c)
},
},
}
</script>