dengjie commit : 发布日期格式解决
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<view style="display: flex;">
|
<view style="display: flex;">
|
||||||
<text class="xw_time">
|
<text class="xw_time">
|
||||||
{{item.pub_time}}
|
{{item.pub_time_str}}
|
||||||
</text>
|
</text>
|
||||||
<text class="xw_time xw_place">
|
<text class="xw_time xw_place">
|
||||||
{{item.pub_name}}
|
{{item.pub_name}}
|
||||||
@@ -21,6 +21,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import {
|
||||||
|
dateFormat
|
||||||
|
} from '../../utills/date.js'
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -52,7 +55,10 @@
|
|||||||
// }
|
// }
|
||||||
getNews() {
|
getNews() {
|
||||||
this.$apiServe.getNews().then(res => {
|
this.$apiServe.getNews().then(res => {
|
||||||
// console.log('行业新闻', res.data.data)
|
console.log('行业新闻', res.data.data)
|
||||||
|
for (const item of res.data.data) {
|
||||||
|
item.pub_time_str = dateFormat(item.pub_time_str)
|
||||||
|
}
|
||||||
this.newsList = res.data.data
|
this.newsList = res.data.data
|
||||||
}).finally(_ => {})
|
}).finally(_ => {})
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
:lazy-load="true">
|
:lazy-load="true">
|
||||||
</u-image>
|
</u-image>
|
||||||
<text class="release">发布日期:</text>
|
<text class="release">发布日期:</text>
|
||||||
<text>{{item.pub_time}}</text>
|
<text>{{item.pub_time_str}}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
16
utills/date.js
Normal file
16
utills/date.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
function dateFormat(time) {
|
||||||
|
let date = new Date(time);
|
||||||
|
let year = date.getFullYear();
|
||||||
|
// 在日期格式中,月份是从0开始的,因此要加0,使用三元表达式在小于10的前面加0,以达到格式统一 如 09:11:05
|
||||||
|
let month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
|
||||||
|
let day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
|
||||||
|
let hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
|
||||||
|
let minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
|
||||||
|
let seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
|
||||||
|
// 拼接
|
||||||
|
return year + "-" + month + "-" + day + " " + hours + ":" + minutes;
|
||||||
|
// return year + "-" + month + "-" + day;
|
||||||
|
}
|
||||||
|
module.exports = {
|
||||||
|
dateFormat
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user