<script>
export default {
data() {
return {
date: ""
};
},
methods: {
queryDate(date) {
if (date.length == 4) {
return date;
} else if (date.length == 6) {
return date.replace(/(\d{4})(\d{2})/, "$1-$2");
} else if (date.length == 8) {
return date.replace(/(\d{4})(\d{2})(\d{2})/, "$1-$2-$3");
} else {
alert("Date 格式错误");
}
}
},
created() {
this.date = this.queryDate("20190203"); // 2019-02-03
}
};
</script>