uniapp 小程序获取设备型号

使用uniapp开发微信小程序时获取手机设备型号很简单,此方法还适用于H5,以及生成的其他小程序,下面给大家写出两种方法实现。 onLoad() { uni.getSystemInfo({ success: function(res)...

使用uniapp开发微信小程序时获取手机设备型号很简单,此方法还适用于H5,以及生成的其他小程序,下面给大家写出两种方法实现。

	onLoad() {
		uni.getSystemInfo({
			success: function(res) {
				console.log(res.model);//获取手机型号
			}
		});
	},

以上方法在生命周期直接调用getSystemInfo函数即可,res除了包含手机型号还包含很多其他属性,下面给出官方地址,大家参考


方法二:

onLoad() {
		//本方法还能获取更多信息
		const res = uni.getSystemInfoSync();
		console.log(res.brand);//获取手机品牌
		console.log(res.model); //获取手机型号
	},

以上方法也是可以的

效果展示:

attachments-2020-12-Sh26kdAp5fd845692da21.png


更多属性请参考:

https://uniapp.dcloud.io/api/system/info?id=getsysteminfo

你可能感兴趣的文章

相关问题

0 条评论

请先 登录 后评论
admin
admin

651 篇文章

作家榜 »

  1. admin 651 文章
  2. 粪斗 185 文章
  3. 王凯 92 文章
  4. 廖雪 78 文章
  5. 牟雪峰 12 文章
  6. 李沁雪 9 文章
  7. 全易 2 文章
  8. Stevengring 0 文章