新版微信小程序的 app.json 文件中多了一個:style": "v2"
{
"pages":[
"pages/index/index",
"pages/logs/logs"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "Weixin",
"navigationBarTextStyle":"black"
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}
fcfaaf51f3deb48f8b49efa3e01f3a292df578ae.png
可以看做是微信小程序基礎組件樣式升級仪缸,使用v2版本的組件樣式默認情況和v1不同,涉及的組件有6個。
例如 button:
<button type="primary">提交</button>
<button type="primary" loading="true">Loading</button>
<button type="primary" disabled="true">Disabled</button>
V2版效果如圖:
QQ截圖20230510110619.png
如果把 "style": "v2", 刪除维费,
{
"pages":[
"pages/index/index",
"pages/logs/logs"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "Weixin",
"navigationBarTextStyle":"black"
},
"sitemapLocation": "sitemap.json"
}
效果如圖:
QQ截圖20230510110648.png
還有其他組件的區(qū)別,就不一一列舉了员萍。
注意:
當使用微信小程序進行開發(fā)時腾降,如果使用vant組件庫或其他組件,刪除 app.json 里面的 "style": "v2" 時碎绎,會導致有的頁面部分樣式失效螃壤。這時候可以把有問題的 .json 后綴的文件里添加上"style": v2就可以了。比如你需要在 user 頁面里使用微信提供的默認樣式筋帖,就在 user.json 里面寫上 “style”: “v2”就可以了奸晴。