因?yàn)橐鲆粋€(gè)app的應(yīng)用升級(jí),網(wǎng)上的普遍寫法是這樣的
plus.runtime.getProperty(plus.runtime.appid, (wgtInfo)=> {
console.log("version:" + wgtInfo.version) ;//例子:獲取版本號(hào)
console.log("code: " + wgtInfo.version.code);
});
啟動(dòng)應(yīng)用時(shí),第一個(gè)打印的是版本名稱,而第二個(gè)直接就是undefined,也就是獲取不到我們設(shè)版本號(hào)
繼續(xù)肝。。。
這是原創(chuàng)作者的鏈接,分享給大家:
https://www.cnblogs.com/houxianzhou/p/13631124.html
上源碼:
mui.plusReady(function(){
mui.getJSON("manifest.json", null, function(manifest){
var versionName = manifest.version.name;
var versionCode = Number(manifest.version.code);
console.log("版本名稱:"+versionName+",版本code:"+versionCode);
});
});
我自己測了是沒有問題的,可以直接拿到name和code
以上就是uniapp如何獲取manifest.json參數(shù)的方法了
如果這篇文章對你有幫助,或者在進(jìn)行中遇到其他問題,歡迎評(píng)論區(qū)留言出來。
我們一起探討~