标签: ionic4

相机无法在IONIC 4上运行的FILE_URI路径

使用Cameara拍照时destinationType: this.camera.DestinationType.FILE_URI,生成的URL无法显示图像.例如,在尝试拍摄这样的照片时:

this.camera.getPicture(options).then((url) => {
        // Load Image
        this.imagePath = url;
    }, (err) => {
        console.log(err);
    });
Run Code Online (Sandbox Code Playgroud)

试图显示它<img [src]="imagePath" >会导致错误(找不到文件).

这里的问题是URL在file:///storage...路径中而不是基于localhost的正确路径.

ionic-framework ionic4

8
推荐指数
1
解决办法
4373
查看次数

工具栏中的Ionic 4 ion-title不在android上居中

我想知道这是否是常见问题。我ion-title不在Android工具栏中。

我用谷歌搜索,但找不到离子4的任何东西,我发现是离子3的很好的解决方案。

在这里是:https : //stackoverflow.com/a/30021395/4983589

我想知道是否有人在ionic4中做到这一点?

这是一张在android上的图片:

在此处输入图片说明

ionic-framework ionic4

8
推荐指数
1
解决办法
3609
查看次数

尝试运行 ng test 时在 multi styles.css 中收到“ERROR”

将 Angular 升级到 7.2.6 后,我可以成功构建使用,ng build但是当我运行时ng test出现以下错误。我已经尝试styles.css在我的angular.json文件中调整路径,但仍然收到相同的错误。我对正在发生的事情不知所措。我也在使用 Ionic 4。

ERROR in multi ./styles.css
Module not found: Error: Can't resolve '/Users/zsoflin/Documents/GitHub/Layer/styles.css' in '/Users/zsoflin/Documents/GitHub/Layer'
resolve '/Users/zsoflin/Documents/GitHub/Layer/styles.css' in '/Users/zsoflin/Documents/GitHub/Layer'
  using description file: /Users/zsoflin/Documents/GitHub/Layer/package.json (relative path: .)
    Field 'browser' doesn't contain a valid alias configuration
    using description file: /Users/zsoflin/Documents/GitHub/Layer/package.json (relative path: ./styles.css)
      no extension
        Field 'browser' doesn't contain a valid alias configuration
        /Users/zsoflin/Documents/GitHub/Layer/styles.css doesn't exist
      .ts
        Field 'browser' doesn't contain a valid alias configuration
        /Users/zsoflin/Documents/GitHub/Layer/styles.css.ts doesn't …
Run Code Online (Sandbox Code Playgroud)

karma-runner angular ionic4

8
推荐指数
1
解决办法
1974
查看次数

从其组件中消除Ionic 4 Popover

我有一个标准的Ionic 4页面(主页),该页面创建一个使用组件(BusinessDetails)和一个按钮的弹出窗口,该按钮重定向到新页面(RequestTurn)。但是,当我单击该按钮时,弹出窗口不会消失,而是呈现在我的RequestTurn页面顶部。我想我需要从组件(BusinessDetails)中手动关闭它,但是我不知道如何从那里访问弹出窗口的实例,因为它是在主页中创建的。有没有办法做到这一点?

home.page.ts

presentModal(business:Business, event: Event) {
this.popoverController.create(({
    component: BusinessDetailsComponent,
    cssClass: "business-popover",
    showBackdrop: true,
    componentProps: {
        business: business
    }
}) as any).then(popover => popover.present()); }
Run Code Online (Sandbox Code Playgroud)

business-detail.component.ts

goToRequestTurn(id: string) {
   //Need to dismiss popver here (?)
   this.router.navigateByUrl(`/request-turn/${id}`); }
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助。

popover ionic4

8
推荐指数
1
解决办法
3193
查看次数

我的硬件“后退按钮操作”在Ionic 4中不起作用

我正在使用Ionic 4应用程序,当用户在移动后退按钮上单击2次时,它应关闭该应用程序,但这没有发生。

这是我的app.component.ts

lastTimeBackPress = 0;
timePeriodToExit = 2000;
@ViewChildren(IonRouterOutlet) routerOutlets: QueryList<IonRouterOutlet>;

constructor(){
this.backButtonEvent();
}

backButtonEvent() {
    document.addEventListener("backbutton", () => { 
      this.routerOutlets.forEach((outlet: IonRouterOutlet) => {
        if (outlet && outlet.canGoBack()) {
            outlet.pop();
        } else if (this.router.url === '/tabs/tab1') {
          if (new Date().getTime() - this.lastTimeBackPress < this.timePeriodToExit) {
            navigator['app'].exitApp(); //Exit from app
            } else {
            this.presentAlertConfirm();
            this.lastTimeBackPress = new Date().getTime();
          }
          // navigator['app'].exitApp(); // work for ionic 4
        }
      });
    });
  }

  async presentAlertConfirm() {
    const alert = await this.alertController.create({ …
Run Code Online (Sandbox Code Playgroud)

ionic-framework angular ionic4

8
推荐指数
4
解决办法
5074
查看次数

如何在 Ionic 4 中集成 Stripe 支付

我是离子框架的新手,并试图在我的应用程序中集成条纹。我做了一些研究,发现只有这个https://ionicframework.com/docs/native/stripe。它解释得不够好。我如何在 .html 文件上实现这个概念,比如为用户提供一个按钮来触发付款?

我也试过这个https://fireship.io/lessons/stripe-elements-angular/但一路上迷路了。

checkout.page.ts

import { Component, OnInit, Input, HostListener } from '@angular/core';
// import { Stripe } from '@ionic-native/stripe/ngx';
import { AuthService } from '../services/auth.service';
import { FirebaseService } from '../services/firebase.service';
import { AngularFireFunctions } from '@angular/fire/functions';
import { Router } from '@angular/router';

import { Observable, of } from 'rxjs';

declare var Stripe;

@Component({
  selector: 'app-rentals',
  templateUrl: './rentals.page.html',
  styleUrls: ['./rentals.page.scss'],
})
export class RentalsPage implements OnInit {

  user$: Observable<User>;

    constructor(
        private router: Router,
      // …
Run Code Online (Sandbox Code Playgroud)

stripe-payments ionic4 angular7

8
推荐指数
0
解决办法
3156
查看次数

如何在带有电容器的离子中重命名平台“App”

如何将平台应用程序名称从“App”重命名为其他名称?

将平台添加到离子电容器项目时,npx cap add ios它会生成ios/App文件夹,但我想将其命名为ios/my-app.

如果可能的话,我想为不同环境(ios/my-app-testios/my-app-prod)的同一个项目添加两个应用程序。

ionic-framework ionic4 capacitor

8
推荐指数
3
解决办法
6254
查看次数

如何检测 Ionic 4 的离子含量组件中的滚动已结束?

在 Ionic v3 ion-content 中,有像“scrollTop”这样的属性。在 Ionic v4 中不再有这些属性......我如何确定用户是否到达了内容的末尾?

https://ionicframework.com/docs/v3/api/components/content/Content/ https://ionicframework.com/docs/api/content

scroll angular ionic4 ion-content

8
推荐指数
1
解决办法
5897
查看次数

错误检查 ANDROID_SDK_ROOT / JAVA_HOME / PATH 环境变量

生成 apk 运行

 离子科尔多瓦构建android

经过一些过程它会产生错误。

我设置了用户变量

ANDROID_HOME = C:\Users\Zohab Ud Din\AppData\Local\Android\Sdk\build-tools\29.0.1

JAVA_HOME = C:\Program Files\Java\jdk-12.0.2

PATH = ...;C:\Users\Zohab Ud Din\AppData\Local\Android\Sdk\platform-tools
Run Code Online (Sandbox Code Playgroud)

我没有在系统变量中添加任何东西

我的错误是

Checking Java JDK and Android SDK versions
Requirements check failed for JDK 8 ('1.8.*')! Detected version: 12.0.2
Check your ANDROID_SDK_ROOT / JAVA_HOME / PATH environment variables.
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\Users\Zohab Ud Din\AppData\Local\Android\Sdk (DEPRECATED)
[ERROR] An error occurred while running subprocess Cordova.



 cordova.cmd build android exited with exit code 1.

Re-running this command with the --verbose flag may provide …
Run Code Online (Sandbox Code Playgroud)

sdk path java-home ionic4

8
推荐指数
1
解决办法
4万
查看次数

错误:在您的 PATH 中找不到本机运行。(离子 4)

最近突然能够将我的应用程序部署到 android 我现在在尝试运行“ionic cordova run android”时收到此错误

[ERROR] native-run was not found on your PATH. Please install it globally: npm i -g native-run
Run Code Online (Sandbox Code Playgroud)

当我在实用程序下运行“离子信息”时,我看到安装了cordova-res 和native-run,但每次仍然出现此错误。

旁注:' npm i -g native-run ' 不能解决这个问题,错误只是再次出现

执行ls /usr/local/lib/node_modules 返回:'ionic cordova npm'(没有本地运行的迹象,应该在那里)

有没有办法可以直接安装到那个位置?任何帮助将不胜感激。

android npm cordova ionic-framework ionic4

8
推荐指数
1
解决办法
7039
查看次数