微信小程序 app.json 里 "style": "v2" 的作用

新版微信小程序的 app.json 文件中多了一個(gè):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

可以看做是微信小程序基礎(chǔ)組件樣式升級(jí),使用v2版本的組件樣式默認(rèn)情況和v1不同,涉及的組件有6個(gè)。

例如 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ū)別,就不一一列舉了。

注意:

當(dāng)使用微信小程序進(jìn)行開(kāi)發(fā)時(shí),如果使用vant組件庫(kù)或其他組件,刪除 app.json 里面的 "style": "v2" 時(shí),會(huì)導(dǎo)致有的頁(yè)面部分樣式失效。這時(shí)候可以把有問(wèn)題的 .json 后綴的文件里添加上"style": v2就可以了。比如你需要在 user 頁(yè)面里使用微信提供的默認(rèn)樣式,就在 user.json 里面寫(xiě)上 “style”: “v2”就可以了。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容