参考链接 https://ext.dcloud.net.cn/plugin?id=827 <template> <view class="e-page"> {{ utils.friendlyDate(timestamp) }} </view> </template> // 直接使用办法 import utils from '@/components/shoyu-date/utils.filter.js'; // 直接使用办法 End export default { data() { return { // 直接使用需要进行声明 utils: utils, // 直接使用需要进行声明 End date: '2019-10-01 08:00:00' }; }, onLoad() { let that = this; // 时间转换为时间戳 // 如果是时间戳直接传递,无需转换 that.timestamp = new Date(this.date).getTime(); console.log(that.timestamp); }, methods: {} }; <template> <view class="e-page"> <uni-date class="inline" :timestr="date"></uni-date> </view> </template> // 组件引用办法 import uniDate from '@/components/shoyu-date/uni-date.vue'; // 组件引用办法 End export default { components: { uniDate }, data() { return { // 如果不传小时的话,计算以每天8点开始计算 date: '2019-10-01 08:00:00', }; }, onLoad() { let that = this; }, methods: {} }; <template> <view class="e-page"> {{ utils.timeTodate('Y-m-d H:i:s index', timestamp) }} </view> </template> // 直接使用办法 import utils from '@/components/shoyu-date/utils.filter.js'; // 直接使用办法 End export default { data() { return { // 直接使用需要进行声明 utils: utils, // 直接使用需要进行声明 End date: '2019/10/01 08:00:00' }; }, onLoad() { let that = this; // 时间转换为时间戳 // 如果是时间戳直接传递,无需转换 that.timestamp = new Date(this.date).getTime(); console.log(that.timestamp); }, methods: {} }; <template> <view class="e-page"> <uni-format class="inline" format="Y-m-d H:i:s index" :timestr="date"></uni-format> </view> </template> // 组件引用办法 import uniDate from '@/components/shoyu-date/uni-date.vue'; // 组件引用办法 End export default { components: { uniDate }, data() { return { // 如果不传小时的话,计算以每天8点开始计算 date: '2019-10-01 08:00:00', }; }, onLoad() { let that = this; }, methods: {} };