在.vue 文件中引入.js文件怎么调用
2021-03-18 10:24
                         标签:item   文件   time   http   html   col   this   数据   别名    1、.js: 2、.vue文件 即实现了将时间戳转换为正常时间格式的效果,其他页面需要转换可以直接调用。 1.可以通过import timeStampChanges from ‘../../../assets/js/timeStampChange‘; 来导入该js文件,timeStampChanges为该文件的别名,通过别名.(方法/数据)来调用。 2.也可以直接import {timeStampChange} from ‘../../../assets/js/timeStampChange‘; 来导入该js文件中的方法/数据,其中{}中的名字即为该js文件中的方法/数据。   转载自:https://www.cnblogs.com/5201314m/p/11962043.html、https://blog.csdn.net/K_520_W/article/details/103547917 在.vue 文件中引入.js文件怎么调用 标签:item   文件   time   http   html   col   this   数据   别名    原文地址:https://www.cnblogs.com/jervy/p/12773645.htmlexport default{
  //时间戳转换为正常时间格式
  timeStampChange:function(time){
    let p = ‘‘;
    var date = new Date(time); // 获取时间戳
    let y = date.getFullYear();
    let MM = date.getMonth() + 1;
        MM = MM 10 ? (‘0‘ + MM) : MM;
    let d = date.getDate();
        d = d 10 ? (‘0‘ + d) : d;
    let h = date.getHours();
        h = h 10 ? (‘0‘ + h) : h;
    let m = date.getMinutes();
        m = m 10 ? (‘0‘ + m) : m;
    let s = date.getSeconds();
        s = s 10 ? (‘0‘ + s) : s;
    p = y + ‘-‘ + MM + ‘-‘ + d + ‘ ‘ + h + ‘:‘ + m + ‘:‘ + s;
    return p;
  }
}
import timeStampChanges from ‘../../../assets/js/timeStampChange‘;
 
this.recordInformation.map(function(item,index){
  item.time = timeStampChanges.timeStampChange(item.time);
})
文章标题:在.vue 文件中引入.js文件怎么调用
文章链接:http://soscw.com/index.php/essay/65729.html