Ionic3 UI組件之 PhotoViewer


PhotoViewer是常用的Cordova Plugin之一,用來顯示圖片。

組件特性:

  • 根據Url顯示圖片
  • 支持手勢,可放大縮小
  • 帶分享按鈕,可分享圖片
  • 帶關閉按鈕
  • 加載錯誤時自動關閉組件
  • 支持Base64

參考地址:https://github.com/sarriaroman/photoviewer

========================================================================

1)安裝插件和包:

ionic cordova plugin add com-sarriaroman-photoviewer

npm install --save @ionic-native/photo-viewer

2)添加插件到app.module.ts:

import { PhotoViewer } from '@ionic-native/photo-viewer';
別忘了
providers:[] 里面加上PhotoViewer;
3)在需要使用的地方:
import { PhotoViewer } from '@ionic-native/photo-viewer';
構造器中:private photoViewer: PhotoViewer
具體使用方法:
this.photoViewer.show('https://images2015.cnblogs.com/news/24442/201705/24442-20170502163240086-1545306933.jpg', '示例圖片');
效果圖:
如果不是暫時網絡圖片,而是相機拍攝的圖片,可以:
this.photoViewer.show(this.base64Image, '示例圖片');
base64Image參看camera插件。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM