Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 从下拉菜单中选择新月份将清除Vuejs中的日期下拉列表_Javascript_Html_Arrays_Vue.js_Drop Down Menu - Fatal编程技术网

Javascript 从下拉菜单中选择新月份将清除Vuejs中的日期下拉列表

Javascript 从下拉菜单中选择新月份将清除Vuejs中的日期下拉列表,javascript,html,arrays,vue.js,drop-down-menu,Javascript,Html,Arrays,Vue.js,Drop Down Menu,我有三个下拉菜单,分别代表出生日期、月份和年份: <input-select id="dateOfBirth" label="Day" :name="'dateOfBirth' | hashcode" :option-default="select dat" :option-list="birthDates" :v-model="birthdate" :value="birthdate"</input-select> <input-sele

我有三个下拉菜单,分别代表出生日期、月份和年份:

<input-select
  id="dateOfBirth"
  label="Day"
  :name="'dateOfBirth' | hashcode"
  :option-default="select dat"
  :option-list="birthDates"
  :v-model="birthdate"
  :value="birthdate"</input-select> 

<input-select
  id="monthOfBirth"
  label="Month"
  :name="'monthOfBirth' | hashcode"
  :option-default="select month"
  :option-list="birthMonth"
  v-model="birthmonth"
  :value="birthMonth"></input-select> 

<input-select 
  id="yearOfBirth"
  label="Year"
  :name="'yearOfBirth' | hashcode"
  :option-list="birthYears"
  :option-default="select year"
  v-model="birthyear"
  :value="birthyear"
></input-select>

确保您的
v-model
出生日期
未在代码中的任何其他位置更新。用计算机或手表。这可能就是原因。另外,我注意到您同时使用了
v-model
:value
。尝试删除
:值

data: function () {
    return {
    //initiating the array which would show the dates
    birthdate:[],
    numDates:''
...
  methods: {
    //the function that would repopulate the birthdate[] array
    birthdateValueList(){
      //erasing the values of the existing array
      this.birthdates = []
      //adding new values
      let i = 1;
      //numDates is defined in another function based on the month selected, please see below
      while (i <= this.numDates){
        this.birthdates.push(i);
        i ++;
      }
...
  // watching the birthmonth drop down and setting the number days for that month
  // this is where we define numDates
  watch: {
    birthmonth:function(){
      if(this.birthmonth === "April" || this.birthmonth === "June" || this.birthmonth === "September" || this.birthmonth === "November"){
        this.numDates = 30
      }else if (this.birthmonth === "February" && this.leapYear){
          this.numDates = 29
        }
         else if(this.birthmonth === "February" && !this.leapYear){
          this.numDates = 28
      }
      else {
        this.numDates = 31
      }
...
  // and then a computed property to do some formatting and returning the final array
  computed: {
    birthDates: function(){
      var list = JSON.parse(JSON.stringify(this.birthdates));
      var birthdateDates = this.generateNewList(list);
      return birthdateDates;
    },