快应用网络异常组件
公共组件
<template>
<div>
<stack class="network" show="{{isShow}}">
<div class="network_wraper">
<image class="network_icon" src="/common/images/notice.png"></image>
<text class="network_tips">{{networkTips}}</text>
</div>
</stack>
</div>
</template>
<script>
export default {
props: {
isShow: {
type: Boolean,
default: false,
},
networkTips: {
type: String,
default: '当前网络不可用,请检查你的网络设置'
}
},
data: {
},
}
</script>
<style lang="less">
.network {
position: fixed;
width: 750px;
height: 80px;
background-color: #ffe1e1;
&_wraper {
width: 750px;
height: 80px;
background-color: #ffe1e1;
display: flex;
flex-direction: row;
align-items: center;
}
&_icon {
width: 36px;
height: 36px;
margin-left: 24px;
}
&_tips {
width: 642px;
height: 62px;
margin-left: 24px;
font-size: 26px;
font-family: Helvetica;
color: rgba(0, 0, 0, 0.8);
line-height: 31px;
}
}
</style>
引用方法
<import name="network-tips" src="../../components/network-tips/index.ux"></import>
<template>
<div class="home-page">
<network-tips is-show='{{net_show}}'></network-tips>
</div>
</template>
<script>
import network from '@system.network'
data:{
net_show: false,
}
// 获取当前网络状态
getNetworkStatus() {
network.subscribe({
callback: (data) => {
this.netFlag = data.type === 'none' ? false : true
this.netStatus = data.type
}
})
},
</script>