vue中 數(shù)字相加為字串轉(zhuǎn)化為數(shù)值的例子
更新時間:2019年11月07日 08:36:30 作者:一抹胭脂冷
今天小編就為大家分享一篇vue中 數(shù)字相加為字串轉(zhuǎn)化為數(shù)值的例子,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
month傳入為3時,下面代碼輸出為31
if(data1.attr === 'last_month') { if(month === 1) { year = year - 1 } else { month = this.trans_Date(month - 1) } } else if(data1.attr === 'next_month') { if(month === 12) { year = year + 1 month = this.trans_Date(1) } else { month=this.trans_Date(month +1); console.log("month", month) } } else { month=this.trans_Date(month) } trans_Date(data) { if (data < 10) { return '0' + data } else { return data } }
控制臺輸出為
想要month+1返回的是數(shù)值,先進行-0在進行+1。
if(data1.attr === 'last_month') { if(month === 1) { year = year - 1 } else { month = this.trans_Date(month - 1) } } else if(data1.attr === 'next_month') { if(month === 12) { year = year + 1 month = this.trans_Date(1) } else { month=this.trans_Date(month-0 +1); console.log("month", month) } } else { month=this.trans_Date(month) }
控制臺輸出為
以上這篇vue中 數(shù)字相加為字串轉(zhuǎn)化為數(shù)值的例子就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
Vue動態(tài)擴展表頭的表格及數(shù)據(jù)方式(數(shù)組嵌套對象)
這篇文章主要介紹了Vue動態(tài)擴展表頭的表格及數(shù)據(jù)方式(數(shù)組嵌套對象),具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-03-03如何優(yōu)雅的在一臺vps(云主機)上面部署vue+mongodb+express項目
這篇文章主要介紹了如何優(yōu)雅的在一臺vps(云主機)上面部署vue+mongodb+express項目,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2019-01-01vue中使用vue-pdf組件實現(xiàn)文件預(yù)覽及相應(yīng)報錯解決
在需求中,經(jīng)常遇見pdf的在線預(yù)覽效果,很多pdf插件不支持vue3,或者是沒有集成翻頁放大縮小功能,比如vue-pdf,下面這篇文章主要給大家介紹了關(guān)于vue中使用vue-pdf組件實現(xiàn)文件預(yù)覽及相應(yīng)報錯解決的相關(guān)資料,需要的朋友可以參考下2022-09-09