使用计算属性实现日期的格式化,只显示年月日
这个要怎么弄呢?
求大神帮忙。。。
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>Document</title><script src="./vue.js"></script></head><body><div id="app"></div><script>new Vue({el: "#app",template: "<h1>{{fullDate}}</h1>",computed: {fullDate: function () {let now = new Date();let year = now.getFullYear();let month = now.getMonth();let date = now.getDate();return `${year}-${month}-${date}`; //根据自己的需要拼接字符串},},});</script></body></html>
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>Document</title><script src="./vue.js"></script></head><body><div id="app"></div><script>new Vue({el: "#app",template: "<h1>{{fullDate}}</h1>",computed: {fullDate: function () {let now = new Date();let year = now.getFullYear();let month = now.getMonth();let date = now.getDate();return `${year}-${month}-${date}`; //根据自己的需要拼接字符串},},});</script></body></html>
01