js封装导出

const Info = {

InformationFun: function(userinfo) {
    var titlearr = [];
    let newtime;
    let timestamp = new Date().getTime();
    if (userinfo.idValiDate != '') {
        // console.log("判断是否过期的一步")
        newtime = this.changemm(userinfo.idValiDate);
        // console.log(newtime,'=======================newtime')
        if (timestamp > newtime) {
            titlearr.push('有效期');
        }
    } else {
        titlearr.push('有效期');
    }

    if (userinfo.isUploadIdcardImg != '1') {
        titlearr.push('照片');
    }
    return titlearr;
},
changemm(timer) {
    //日期转为时间戳格式
    //后面加的57599000是因为格式2021-08-10转化为时间戳的到的毫秒,在转化为具体时间的是2021-08-10 08:00:00,
    //需要加上57599000让其变为2021-08-10 23:59:59
    var endDate = new Date(timer).getTime() + 57599000; //得到毫秒数
    return endDate;
},

}
module.exports = {
InformationFun: Info.InformationFun
}

//
以上是我js代码,我在需要的页面导入之后,获取不到InformationFun这个函数,那个hxd帮帮忙,唔该晒

//页面
import {userInfoHandler} from '@/commom/userInfo';

没办法得到userInfoHandler里面的InformationFun函数

阅读 1.7k
1 个回答

你引入错了。。。
import命令接受一对大括号,里面指定要从其他模块导入的变量名。大括号里面的变量名,必须与被导入模块对外接口的名称相同。

import {InformationFun} from '@/commom/userInfo'
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题