开发者工具版本:1.06.2206090
报错
[ app.json 文件内容错误] app.json: ["tabBar"]["list"][1]["iconPath"]: "static/tab_icons/cate.png" 未找到
(env: Windows,mp,1.06.2206090; lib: 2.19.4)
现象
原因
图片相对路径写错,相对路径是相对根目录的路径。
解决
1.目录层级放在根目录下,即与pages同级;
// app.json
{
"pages":[
"pages/home/home",
"pages/cate/cate",
"pages/cart/cart",
"pages/my/my",
"pages/index/index",
"pages/logs/logs"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#66ccff",
"navigationBarTitleText": "橱窗展示",
"navigationBarTextStyle":"black",
"enablePullDownRefresh": true,
"backgroundColor": "#66ccff"
},
"tabBar":{
"list":[
{
"pagePath":"pages/home/home",
"text":"首页",
"iconPath":"static/tab_icons/home.png",
"selectedIconPath":"static/tab_icons/home-active.png"
}, {
"pagePath":"pages/cate/cate",
"text":"分类",
"iconPath":"static/tab_icons/cate.png",
"selectedIconPath":"static/tab_icons/cate-active.png"
}, {
"pagePath":"pages/cart/cart",
"text":"购物车",
"iconPath":"static/tab_icons/cart.png",
"selectedIconPath":"static/tab_icons/cart-active.png"
}, {
"pagePath":"pages/my/my",
"text":"我的",
"iconPath":"static/tab_icons/my.png",
"selectedIconPath":"static/tab_icons/my-active.png"
}
],
"color": "#f5f6fa",
"selectedColor": "#54a0ff",
"backgroundColor": "#66ccff"
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}
2.目录层级放在pages目录下,路径为:pages/xxx/yyy.png。
// app.json
{
"pages":[
"pages/home/home",
"pages/cate/cate",
"pages/cart/cart",
"pages/my/my",
"pages/index/index",
"pages/logs/logs"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#66ccff",
"navigationBarTitleText": "橱窗展示",
"navigationBarTextStyle":"black",
"enablePullDownRefresh": true,
"backgroundColor": "#66ccff"
},
"tabBar":{
"list":[
{
"pagePath":"pages/home/home",
"text":"首页",
"iconPath":"pages/home/static/tab_icons/home.png",
"selectedIconPath":"pages/home/static/tab_icons/home-active.png"
}, {
"pagePath":"pages/cate/cate",
"text":"分类",
"iconPath":"pages/cate/static/tab_icons/cate.png",
"selectedIconPath":"pages/cate/static/tab_icons/cate-active.png"
}, {
"pagePath":"pages/cart/cart",
"text":"购物车",
"iconPath":"pages/cart/static/tab_icons/cart.png",
"selectedIconPath":"pages/cart/static/tab_icons/cart-active.png"
}, {
"pagePath":"pages/my/my",
"text":"我的",
"iconPath":"pages/my/static/tab_icons/my.png",
"selectedIconPath":"pages/my/static/tab_icons/my-active.png"
}
],
"color": "#f5f6fa",
"selectedColor": "#54a0ff",
"backgroundColor": "#66ccff"
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}
备注
1.首先要保证路径里的图片真的有,名字不要写错,然后再讨论路径的书写规则。文章来源:https://www.toymoban.com/news/detail-504566.html
2.没有深挖原因,只是按以上方法改了之后就不报错了,刚开始学,仅供参考。文章来源地址https://www.toymoban.com/news/detail-504566.html
到了这里,关于【微信小程序】【微信开发者工具】[ app.json 文件内容错误] app.json: [“tabBar“][“list“][1][“iconPath“]: “xxx/yyy.png“ 未找到的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!