課程
/前端開發(fā)
/Vue.js
/vue2.5入門
使用計算屬性實現(xiàn)日期的格式化,只顯示年月日
這個要怎么弄呢?
求大神幫忙。。。
2020-09-20
源自:vue2.5入門 2-5
正在回答
<!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}`;?//根據(jù)自己的需要拼接字符串},},});</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}`; //根據(jù)自己的需要拼接字符串},},});</script></body></html>
01
舉報
快速理解Vue編程理念上手Vue2.0開發(fā)。
1 回答vue的計算屬性
1 回答計算屬性和監(jiān)聽器
3 回答computed計算屬性提示錯誤
5 回答求解button的文字屬性
1 回答數(shù)據(jù)中的屬性問題
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2020-09-21
2021-01-03
<!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}`; //根據(jù)自己的需要拼接字符串},},});</script></body></html>
01