h***@qq.com
h***@qq.com
  • 发布:2019-12-11 17:30
  • 更新:2020-09-17 20:47
  • 阅读:1766

已找到问题,components里不能写js名,webapp里的js在自定义组件模式下小程序测试没有生成文件

分类:HBuilderX

详细问题描述

jsEnginScriptError
Component is not found in path "components/timeformat/time_format" (using by "pages/index/index");onAppRoute
Error: Component is not found in path "components/timeformat/time_format" (using by "pages/index/index")

重现步骤

用自定义组件模式创建工程,创建一个js工具,在index.vue里引入js,运行到小程序模拟器微信,页面报错如上,微信小程序工程里根本没有这个js

time_format.js代码

/**  
 * 返回YYYY-MM-DD HH:MM  
 */  
function formatTime(date, fmt) {  
    if (date) {  
        if (typeof date === 'string') {  
            date = new Date(date)  
        }  
        if (!fmt) {  
            fmt = 'yyyy/MM/dd hh:mm';  
        }  
        var o = {  
            'M+': date.getMonth() + 1, //月份  
            'd+': date.getDate(), //日  
            'h+': date.getHours(), //小时  
            'm+': date.getMinutes(), //分  
            's+': date.getSeconds(), //秒  
            'q+': Math.floor((date.getMonth() + 3) / 3), //季度  
            S: date.getMilliseconds() //毫秒  
        }  
        if (/(y+)/.test(fmt)) {  
            fmt = fmt.replace(  
                RegExp.$1,  
                (date.getFullYear() + '').substr(4 - RegExp.$1.length)  
            )  
        }  
        for (var k in o) {  
            if (new RegExp('(' + k + ')').test(fmt)) {  
                fmt = fmt.replace(  
                    RegExp.$1,  
                    RegExp.$1.length == 1 ?  
                    o[k] :  
                    ('00' + o[k]).substr(('' + o[k]).length)  
                )  
            }  
        }  
        return fmt;  
    }  
}  

export default formatTime

[期望]

微信小程序工程里正常存在这个js

IDE运行环境说明

HbuilderX 2.4.6.20191210

windows10

uni-app运行环境说明

app在小程序测试

[运行端版本号]

[项目是cli创建的还是HBuilderX创建的?如果是cli创建的,请更新到最新版cli再试]

HBuilderX创建

[编译模式是老模板模式还是新的自定义组件模式?]

自定义组件模式

App运行环境说明

[Android版本号]

[iOS版本号]

[手机型号]

[模拟器型号]

附件

[IDE问题请提供HBuilderX运行日志。菜单帮助-查看运行日志,点右键打开文件所在目录,将log文件压缩成zip包上传]

[App问题请提供可重现问题的代码片段,你补充的细一点,问题就解决的快一点]

[App安装包或H5地址]

[可重现代码片段]

联系方式

[QQ]

2019-12-11 17:30 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复