cordova-plugin-network-information 2.0.1
1 安装插件 cordova plugin add cordova-plugin-network-information
```
if (navigator.connection) {
var tmptypes = navigator.connection.type;
if (tmptypes.toUpperCase().indexOf('NONE') > -1 || tmptypes.toUpperCase().indexOf('UNKNOWN') > -1) {
if (navigator.notification) {
navigator.notification.confirm('您的设备未开启网络',function (buttonIndex) {
if (buttonIndex == 1) {
if (cordova.plugins.settings) {
cordova.plugins.settings.openSetting("wifi", function () { console.log("network setting openning"); }, function () { console.log("open network setting failed"); });
}
}
}, // callback to invoke with index of button pressed
'提示', // title
['开启', '取消'] // buttonLabels
);
}
}
}
```
网友评论