When elment selects the month, the format is yyyy-MM. Change the format according to the requirements of the backend

When selecting a month, for example, this format 2023.08 is also based on the back-end requirements. The back-end requirements for this month are not as fast as January-September. There is no need to fill in 0. The back-end should be 2023.8 

Because one field cannot be realized, the bound month selection is divided into two fields year month Add a change event to the selected month

   startYearAndMonth(val) {
            if (val) {
                this.formInline.year = val.substr(0, 4)
              
                if(val.substr(5,1) == 1){
                    this.formInline.month = val.substr(5, 2)
                }else{
                    this.formInline.month = val.substr(6, 1)
                }
               
            } else {
                this.formInline.year = ''
                this.formInline.month = ''
            }

        },

 The year is to intercept the first four digits through substr. If the fifth digit is 0, take one from the sixth digit; otherwise, take two from the fifth digit.

 

 

 

Guess you like

Origin blog.csdn.net/weixin_69811594/article/details/130262598