1. Recently, I am doing a conversion about the week. I can convert the week of the number, but I don"t know how to convert it if I want to convert it to uppercase. I think of using the switch sentence, but I don"t know how to do it. Please give me some advice
.2. Create a new filter folder and create an index file
export default function (Vue) {
Vue.filter("dateDate", function (tplData) {
let dateMM = tplData ? new Date(tplData) : new Date();
return `${dateMM.getFullYear()}/${dateMM.getMonth() + 1}/${dateMM.getDate()}`;
});
Vue.filter("mDate", function (tData) {
let dateTT = tData ? new Date(tData) : new Date();
let hours = dateTT.getHours() < 10 ? "0" : "";
let min = dateTT.getMinutes() < 10 ? "0" : "";
return `${hours + dateTT.getHours()}:${min + dateTT.getMinutes()}`;
});
Vue.filter("myDate", function (txData) {
let dateT = txData ? new Date(txData) : new Date();
return `${dateT.getDay()}`;
});
};
3. Refer to the file that needs to be converted
<!-- -->
<div class="litter_date">
<div class="time clearfix">
{{ datetime | mDate }}
<div class="date">
<div>{{datetime | dateDate}}</div>
<span>{{datetime | myDate}}</span>
</div>
</div>
</div>
data() {
return {
datetime: "",
};
},
4. Final display effect