当前位置: 代码迷 >> 综合 >> 小程序出现:Component is not found in path “components/xxx/xxx”问题
  详细解决方案

小程序出现:Component is not found in path “components/xxx/xxx”问题

热度:57   发布时间:2023-11-26 05:49:59.0

今天学习小程序,测试组件时出现以下异常

VM1178:1 jsEnginScriptError
Component is not found in path "components/like/index" (using by "pages/classic/classic")
Error: Component is not found in path "components/like/index" (using by "pages/classic/classic")at e (http://127.0.0.1:30310/appservice/__dev__/WAService.js:1:541205)at e (http://127.0.0.1:30310/appservice/__dev__/WAService.js:1:541391)at $ (http://127.0.0.1:30310/appservice/__dev__/WAService.js:1:541533)at Object.t.addView (http://127.0.0.1:30310/appservice/__dev__/WAService.js:1:542969)at Function.value (http://127.0.0.1:30310/appservice/__dev__/WAService.js:1:606049)at Ct (http://127.0.0.1:30310/appservice/__dev__/WAService.js:1:620199)at Et (http://127.0.0.1:30310/appservice/__dev__/WAService.js:1:621887)at Tt (http://127.0.0.1:30310/appservice/__dev__/WAService.js:1:623096)at Function.<anonymous> (http://127.0.0.1:30310/appservice/__dev__/WAService.js:1:624000)at dt.<anonymous> (http://127.0.0.1:30310/appservice/__dev__/WAService.js:1:592901)

 

经过调整,正确测试代码以及代码目录结构如下:

 

1、index.js代码必有组件构造函数:

Component({})

2、index.json代码必有以下配置:

{"component": true,"usingComponents":{}
}

3、其中,classic目录为引用组件页面,代码如下:

{"usingComponents":{"v-like":"/components/like/index"}
}

 

其中,缺少1情况会报异常:

VM1523:1 jsEnginScriptError
Component is not found in path "components/like/index" (using by "pages/classic/classic")
Error: Component is not found in path "components/like/index" (using by "pages/classic/classic")at e (http://127.0.0.1:30310/appservice/__dev__/WAService.js:1:541205)at e (http://127.0.0.1:30310/appservice/__dev__/WAService.js:1:541391)at $ (http://127.0.0.1:30310/appservice/__dev__/WAService.js:1:541533)at Object.t.addView (http://127.0.0.1:30310/appservice/__dev__/WAService.js:1:542969)at Function.value (http://127.0.0.1:30310/appservice/__dev__/WAService.js:1:606049)at Ct (http://127.0.0.1:30310/appservice/__dev__/WAService.js:1:620199)at Et (http://127.0.0.1:30310/appservice/__dev__/WAService.js:1:621887)at Tt (http://127.0.0.1:30310/appservice/__dev__/WAService.js:1:623096)at Function.<anonymous> (http://127.0.0.1:30310/appservice/__dev__/WAService.js:1:624000)at dt.<anonymous> (http://127.0.0.1:30310/appservice/__dev__/WAService.js:1:592901)

缺少2情况中的任何一项会报异常:

VM1845:1 Fri Nov 30 2018 20:59:54 GMT+0800 (中国标准时间)  components/like/index.json 文件错误
VM1845:2 components/like/index.json 文件解析错误  SyntaxError: Unexpected token / in JSON at position 27
(anonymous) @ VM1845:2
VM1847:1 Fri Nov 30 2018 20:59:54 GMT+0800 (中国标准时间)  components/like/index.json 文件错误
VM1847:2 components/like/index.json 文件解析错误  SyntaxError: Unexpected token / in JSON at position 27

 

小编只是新手,大家有问题可以随时评论。小编一定会看,但不能保证一些问题会及时回复。谢谢观看!

  相关解决方案