微信小程式——自定義元件時,編譯報`Component is not found in path '...'`
阿新 • • 發佈:2018-11-23
問題描述:
在微信小程式中自定義元件時,編譯報Component is not found in path '...'
VM4941:1 jsEnginScriptError
Component is not found in path "components/watermark/watermark" (using by "pages/login/login")
Error: Component is not found in path "components/watermark/watermark" (using by "pages/login/login")
at e (http ://127.0.0.1:48631/appservice/__dev__/WAService.js:13:26480)
at e (http://127.0.0.1:48631/appservice/__dev__/WAService.js:13:26632)
at W (http://127.0.0.1:48631/appservice/__dev__/WAService.js:14:749)
at Object.t.addView (http://127.0.0.1:48631/appservice/__dev__/WAService.js:14:1759)
at Function.value (http://127.0 .0.1:48631/appservice/__dev__/WAService.js:15:25997)
at j (http://127.0.0.1:48631/appservice/__dev__/WAService.js:15:4246)
at U (http://127.0.0.1:48631/appservice/__dev__/WAService.js:15:6628)
at G (http://127.0.0.1:48631/appservice/__dev__/WAService.js:15:6894)
at Function.<anonymous> (http://127.0.0.1:48631 /appservice/__dev__/WAService.js:15:9282)
at http://127.0.0.1:48631/appservice/__dev__/WAService.js:15:14950
解決方法:
確認自定義的元件的js
檔案是否存在Component
構造器
Component({
});
確保要引入的頁面的json
檔案中的usingComponents
的path
是正確的:
檔案路徑:
這裡的路路徑有兩種寫法:
{
"usingComponents": {
"watermark" : "/components/watermark/watermark"
}
}
{
"usingComponents": {
"watermark": "../../components/watermark/watermark"
}
}