var app = require('app');
var companyId = app.getAllQueries().companyId;
new Vue({
el: '#confirm',
data: {
birthday: '',
},
created() {
},
mounted() {
this.getBirthdayFromIdCard(身份证号)//方法调用,写在哪儿都可以。注意this指向
},
methods: {
getBirthdayFromIdCard(idCard) {
var birthday = "";
if (idCard != null && idCard != "") {
if (idCard.length == 15) {
birthday = "19" + idCard.substr(6, 6);
} else if (idCard.length == 18) {
birthday = idCard.substr(6, 8);
}
this.birthday = birthday.replace(/(.{4})(.{2})/, "$1-$2-");
}
return birthday;
},
}
})