ionic3常用插件

圖片放大

1.安裝node包

npm install --save ionic-img-viewer

2.在app.module.ts文件中增加:

import { IonicImageViewerModule } from 'ionic-img-viewer';

并且在imports: [] 中增加IonicImageViewerModule;?


3.在使用圖片的地方增加imageViewer屬性

<img??src="http://img1.udiao.com/image/180516/134650478468_370771_1.jpg"? imageViewer="http://img1.udiao.com/image/180516/134650478468_370771_3.jpg" />

禁止屏幕旋轉(zhuǎn)

1.安裝插件

Ionic cordova plugin add cordova-plugin-screen-orientation


2.修改config.xml文件

<preference name="orientation" value="portrait" />


orientation設(shè)置可以讓你鎖定應(yīng)用程序屏幕方向以阻止屏幕自動(dòng)翻轉(zhuǎn)??蛇x的值有:default,landscape(橫屏),portrait(豎屏)。

設(shè)置全屏 (只用于android,ios默認(rèn)全屏 )

1.安裝插件

ionic cordova plugin add cordova-plugin-fullscreen


2.修改?config.xml?文件,添加如下代碼,value?為真假控制是否為全屏程序

<preference name="Fullscreen" value="true">


3.在app.component.ts文件里加入引用;

import?{?Nav,?Platform?}?from?'ionic-angular';

import?{?StatusBar,?Splashscreen?}?from?'ionic-native';

4.修改app.component.ts里的構(gòu)造函數(shù),保持引用切換回來的時(shí)候任然全屏

constructor(private platform: Platform){

??? this.platform.ready().then(() => {

??????? StatusBar.hide();

??????? document.addEventListener('resume',()=>{

??????????? StatusBar.hide();

});

??? });

}


5.ios 默認(rèn)全屏,index.html中

<meta?name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容