![](https://csdnimg.cn/release/download_crawler_static/89372836/bg1.jpg)
实验一:
运行结果截图:
![](https://csdnimg.cn/release/download_crawler_static/89372836/bg2.jpg)
![](https://csdnimg.cn/release/download_crawler_static/89372836/bg3.jpg)
app.wxss:
.container{
display: flex;
flex-direction: column;
min-height: 100%;
font-size: 36rpx;
text-align: center;
justify-content: space-between;
padding: 10rpx;
}
.title{
font-size: 40rpx;
margin: 15rpx;
}
.demo-box{
border: 1rpx solid silver;
margin: 10rpx;
padding: 10rpx;
}
navigator{
text-align: left;
border-bottom: 1rpx solid silver;
margin: 15rpx;
padding: 10rpx;
}
app.json
{
"pages": [
"pages/index/index",
"pages/getSysInfo/getSysInfo",
"pages/compass/compass"
],
"window": {
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black",
"navigationBarTitleText": "第十章 设备 api",
"backgroundColor": "#eeeeee",
"backgroundTextStyle": "light"
},
"sitemapLocation": "sitemap.json"
}
![](https://csdnimg.cn/release/download_crawler_static/89372836/bg4.jpg)
Index---index.wxml(主页)
<!--
学号:2021710151
姓名:张浩
日期:2024.05.22
程序:设备 api
-->
<view class="container">
<view class="demo-box">
<view class="title">系统信息</view>
<navigator url="/pages/getSysInfo/getSysInfo">获取系统信息</navigator>
</view>
<!--传感器-->
<view class="demo-box">
<view class="title">2.传感器</view>
<navigator url="/pages/compass/compass">1.传感器罗盘的应用</navigator>
</view>
</view>
getSysInfo---getSysInfo.wxml(获取系统
信息)
<!--
学号:2021710151
姓名:张浩
日期:2024.05.22
程序:获取系统信息
-->
<view class="container">
<view class="title">1.系统信息</view>
<view class="demo-box">
<view>获取系统信息</view>
<button type="primary" size="mini" bindtap="getSysInfo">异步获取</button>
<button type="primary" size="mini" bindtap="getSysInfoSync">同步获取</button>
<button type="primary" size="mini" bindtap="reset">清空</button>
<!-- 展现手机品牌、型号、操作系统、客户端平台、微信版本 -->
<view class="title">手机品牌:{{res.brand}}</view>
<view class="title">手机型号{{res.model}}</view>
<view class="title">操作系统{{res.system}}</view>
<view class="title">客户端平台{{res.platform}}</view>
<view class="title">微信版本{{res.version}}</view>
</view>