写完小组件以后运行报错(html
组件json("component": true)和引用组件页面json都按规范写没有问题,js没有问题,编译没有问题的状况下)啥问题没有就是报错:json
Error: Component is not found in path “components /my_toast/my_toast” (using by "pages"/index/index)小程序
index页面的路径是 miniprogram/pages/index/indexwindows
my_toast组件的路径是 miniprogram/components/my_toast/my_toast (解决后路径)工具
报错位置是:my_toast.json开发工具
1 { 2 "usingComponents":{ 3 "error_toast":"../../components/my_toast/my_toast" 4 } 5 }
解决方案:spa
1)使用公众开放平台注册的小程序(非开发工具上的“小程序”,“小游戏”,demo)根据AppID 打开会自动建立code
cloudfunctions ; mineprogram 目录,新建 component 须要在 mineprogram目录下建立,不能够与mineprogram同级component
2)检查路径htm
编写正确路径:相对路径和绝对路径 (取自:https://zhidao.baidu.com/question/54621865.html @awerlasdfwe )
Linux :右斜杠(' / ')Windows:左斜杆(' \ ')
绝对路径:是从盘符开始的路径,形如
C:\windows\system32\cmd.exe
相对路径:是从当前路径开始的路径,假如当前路径为C:\windows
要描述上述路径,只需输入
system32\cmd.exe
实际上,严格的相对路径写法应为
.\system32\cmd.exe
其中,.表示当前路径,在通道状况下能够省略,只有在特殊的状况下不能省略。
假如当前路径为c:\program files
要调用上述命令,则须要输入
..\windows\system32\cmd.exe
其中,..为父目录。
当前路径若是为c:\program files\common files
则须要输入
..\..\windows\system32\cmd.exe
另外,还有一种不包含盘符的特殊绝对路径,形如
\windows\system32\cmd.exe
不管当前路径是什么,会自动地从当前盘的根目录开始查找指定的程序。
以前组件名 :toast (这是一个弹窗提示)
问题:
运行后发现弹出是wx.toast ,而非个人自定义组件
缘由:
组件名不能与wx组件冲突
解决:
重命名:my_toast