ionic3根页面设置问题、menu侧滑按钮不显示和显示按钮不显示遮罩层的问题

一:根页面设置

原来APP开始启动时,我将登录页设置为rootPage,登录成功后我跳转到home界面的方法如下:

this.modalCtrl.create(TabsPage);
modal.present();
这种方式并没有将App的根页面转换为TabsPage,以至于后期我想加入一个侧滑菜单时,需要重新设置TabsPage为根页面,否则menuToggle按钮不会显示,解决方案如下:
 this.navCtrl.setRoot(TabsPage);

即在登录成功跳转时采用这种方式即可。

二:不显示遮罩层

这个问题是因为我把menu菜单和home界面写到了一个html里,按说这种方式应该也可以的,但是出现了这个奇怪的问题。

解决方案如下:将menu菜单页放入app.html           这也是ionic3官网上的使用方式

//app.html

<ion-nav [root]="rootPage" #mycontent></ion-nav>
<ion-menu [content]="mycontent" type="overlay" side="left">
  <ion-header>
    <ion-toolbar>
      <ion-title>Menu</ion-title>
    </ion-toolbar>
  </ion-header>
  <ion-content>
    <ion-list>
      <button ion-item *ngFor="let p of pages" (click)="openPage(p)" detail-none>
        {{p.title}}
      </button>
    </ion-list>
  </ion-content>
</ion-menu>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在 Ionic-Angular 应用程序中打开手机的图库并在页面中显示图像,可以使用 Cordova 插件 "cordova-plugin-filechooser" 和 "cordova-plugin-filepath"。 首先,在终端中进入 Ionic-Angular 项目的目录,运行以下命令来安装这两个插件: ``` ionic cordova plugin add cordova-plugin-filechooser npm install --save @ionic-native/file-chooser ionic cordova plugin add cordova-plugin-filepath npm install --save @ionic-native/file-path ``` 然后,在你的组件中导入 `FileChooser` 和 `FilePath`: ```typescript import { FileChooser } from '@ionic-native/file-chooser/ngx'; import { FilePath } from '@ionic-native/file-path/ngx'; ``` 接下来,在组件的构造函数中注入 `FileChooser` 和 `FilePath`: ```typescript constructor( private fileChooser: FileChooser, private filePath: FilePath ) {} ``` 在你的页面中添加一个按钮,当用户点击该按钮时,调用 `openGallery` 方法来打开图库: ```html <ion-button (click)="openGallery()">打开图库</ion-button> ``` 在组件中实现 `openGallery` 方法: ```typescript async openGallery() { try { const uri = await this.fileChooser.open(); const filePath = await this.filePath.resolveNativePath(uri); this.imageSrc = filePath; } catch (e) { console.error(e); } } ``` 在这个方法中,我们使用 `FileChooser` 来打开图库并返回图像的 URI。然后,我们使用 `FilePath` 来将 URI 转换为本地文件路径。最后,我们将图像路径赋值给 `imageSrc` 变量,以便在页面中显示。 在页面中添加一个 `img` 元素来显示图像: ```html <img [src]="imageSrc"> ``` 现在,当用户点击 "打开图库" 按钮时,将会打开图库并选择一个图像。选中的图像将会显示在页面上的 `img` 元素中。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值