标签: ionic-framework

由于 node-sass 错误,Ionic 无法构建应用程序

我正在尝试部署我的 ionic 应用程序,但它不断抛出以下错误:

ionic2Project@2.4.1 build /builds//awaken-app
> ionic-app-scripts build

/builds///node_modules/@ionic/app-scripts/node_modules/node-sass/lib/binding.js:15
      throw new Error(errors.missingBinary());
      ^

Error: Missing binding /builds///node_modules/@ionic/app-scripts/node_modules/node-sass/vendor/linux-x64-64/binding.node
Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 10.x

Found bindings for the following environments:
  - OS X 64-bit with Node.js 12.
Run Code Online (Sandbox Code Playgroud)

这似乎与工作node-sass@4.12.0,但ionic-app-scripts具有node-sass@4.10.0在它的package.json。

当我尝试在node-sass本地重建时,我看到以下错误:

$ npm rebuild node-sass

> node-sass@4.10.0 install /Users//node_modules/node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.10.0/darwin-x64-72_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v4.10.0/darwin-x64-72_binding.node": 

HTTP error 404 …
Run Code Online (Sandbox Code Playgroud)

sass node.js ionic-framework node-sass

3
推荐指数
1
解决办法
4001
查看次数

卡片上的离子长按事件

如何在 Ionic 中为卡片设置长按事件以启动特定卡片的操作表。帮我把这个长按事件绑定到离子

ionic-framework

3
推荐指数
1
解决办法
6828
查看次数

Ionic/Angular 如何从输入中删除边框

我在输入字段中得到以下黑色边框。如何删除控件周围丑陋的 1px 边框?

我在 CSS 中找不到它,或者不知道如何查找它,因为我是新手。

代码:

<ion-col col-8>
    <input formControlName="cardno" placeholder="{{ 'PAYMENT_CARD_NUMBER' | translate }}" card-number />
</ion-col>
Run Code Online (Sandbox Code Playgroud)

结果输入周围有丑陋的 1px 边框:

在此处输入图片说明

css sass ionic-framework angular

3
推荐指数
1
解决办法
1845
查看次数

离子事件替换为 Angular Observables

我知道 Ionic 事件将在下一个版本中被弃用。目前,我使用事件从子组件执行父页面中的函数。下面是一个例子:

在我的主页中,它订阅了要刷新的事件:

constructor(){
  this.eventFormRefresh = (obj) => {
    this.fetch(obj.isReset);
  };
  this.events.subscribe('form:refresh', this.eventFormRefresh);
}

ngOnDestroy(): void {
  this.events.unsubscribe('form:refresh', this.eventFormRefresh);
}
Run Code Online (Sandbox Code Playgroud)

在子组件中,我通过发布 'form:refresh' 事件来激活刷新,如下所示:

this.events.publish('form:refresh');
Run Code Online (Sandbox Code Playgroud)

我将如何使用 angular observables 执行上述操作?

observable ionic-framework angular

3
推荐指数
2
解决办法
6831
查看次数

尝试列出 Firestore 数据库的集合

我想列出 Ionic4 应用程序中 Firestore 数据库的集合,因此我使用了listCollection 部分中的文档,因此我在代码中应用了示例代码:

this.afs.firestore.listCollections().then(collections => {
  for (let collection of collections) {
    console.log(`Found collection with id: ${collection.id}`);
  }
});
Run Code Online (Sandbox Code Playgroud)

这是我的构造函数:

  constructor(private router: Router,
              private afs: AngularFirestore,
              private fireauth: AngularFireAuth) { }
Run Code Online (Sandbox Code Playgroud)

我收到此错误:错误 TS2339:“Firestore”类型上不存在属性“listCollections”。

我不能使用属性 listCollections 而它在在线文档中...

firebase ionic-framework angular google-cloud-firestore

3
推荐指数
1
解决办法
3206
查看次数

如何动态定位 IonPopover 以从按钮出现?

当单击该按钮时,我试图将弹出框放置在该按钮下方。这方面的一个例子在 Ion 文档页面上。在此处输入图片说明

然而,React 中不提供此代码,仅在 Angular 中提供。

目前我的代码看起来像这样

...
<IonButtons slot="end">
                        <IonButton onClick={() => setShowPopover(true)} expand="block">
                            <IonIcon icon={more}/>
                        </IonButton>
                    </IonButtons>
                    <IonPopover
                        isOpen={showPopover}
                        backdropDismiss={true}
                        onDidDismiss={() => setShowPopover(false)}>
                        <IonItem>Popover Item</IonItem>
                    </IonPopover>
...
Run Code Online (Sandbox Code Playgroud)

弹出框由其上方的按钮切换。当按钮被按下时,弹出框出现在页面中间,而不是按钮上方。如何更改此设置以便弹出框显示在按钮上?(就像图片一样)

谢谢

popover typescript reactjs ionic-framework ionic-react

3
推荐指数
1
解决办法
1484
查看次数

Ionic 4 使用 Apple 登录

拜托,你能帮我吗?我想添加使用 ionic 4 登录但没有文档我只找到了这个https://www.npmjs.com/package/cordova-plugin-sign-in-with-apple但不知何故我无法使用。

非常感谢

sign ionic-framework

3
推荐指数
1
解决办法
2211
查看次数

如何在离子应用程序中设置默认图像

我正在尝试向离子应用程序添加默认图像。目前,我正在通过数据库表行中的链接获取应用程序内的图像。但是,如果图像不再存在或链接已损坏,我希望应用程序显示default/fall-back图像而不是这个默认的撕开绘画图标。

这是我尝试让它工作的方法之一,但它没有。

        <ion-card transparent class="detailView" *ngFor="let act of activities">
        <img class="img" src="{{act.image}}"
        onerror="this.src='assets/imgs/defualt.jpg';" alt = "Missing Image" />
Run Code Online (Sandbox Code Playgroud)

{{act.image}}与数据库对话,准确地与数据库中的活动表对话并提取图像链接。如果无法显示图像,如何实现默认选项?

一些额外的花絮;该应用程序是用Ionic框架编写的,并实现了Typescript、Sass和Angular 的使用。

javascript typescript ionic-framework angular ionic4

3
推荐指数
1
解决办法
2266
查看次数

“[(ngModel)]”在 Ionic 4 中没有绑定

我正在构建一个 Ionic 应用程序,目前正在从 Ionic 3 迁移到 4。我有一些代码可以在 Ionic 3 中完美运行,但在 4 中却没有。基本上,我似乎无法使用 [(ngModel)] 绑定数据在输入字段中。我已经FormsModule将它导入并添加到我的app.module.ts. 这是我的-component.ts文件的样子:

export class SomeComponent implements OnInit {
  someString: string = "test";
  ...
}
Run Code Online (Sandbox Code Playgroud)

和我的 -component.html

<ion-input type="text" [(ngModel)]="someString"></ion-input>
{{someString}}
Run Code Online (Sandbox Code Playgroud)

现在在我的应用程序中,{{someString}}正确显示“测试”。但是,更改输入值不会someString以任何方式影响变量。我可能会错过什么?

ionic-framework angular ionic4

3
推荐指数
1
解决办法
4146
查看次数

使用反应形式的 ionic 5 和 Angular 9 出现错误“没有名称的表单控件的值访问器”

我正在使用 ionic 5 和 Angular 9。我正在尝试创建一个反应式表单,但出现错误“没有名称的表单控件的值访问器:'姓氏'”。

这是我的代码:

export class ModalComponent implements OnInit {

  public form: FormGroup;

  constructor(private modalController: ModalController,
              private formBuilder: FormBuilder) { }

  ngOnInit(): void {
    this.initForm();
  }

  public close(): void {
    // using the injected ModalController this page
    // can "dismiss" itself and optionally pass back data
    this.modalController.dismiss({
      'dismissed': true
    });
  }

  public initForm(): void {
    this.form = this.formBuilder.group({
      firstname: ['', Validators.required],
      lastname: ['', Validators.required]
    });
  }

  logForm(){
    console.log(this.form.value)
  }
}
Run Code Online (Sandbox Code Playgroud)
<form [formGroup]="form" (ngSubmit)="logForm()" novalidate>
    <ion-item>
      <ion-label>Last name</ion-label> …
Run Code Online (Sandbox Code Playgroud)

ionic-framework reactive-forms angular angular9 ionic5

3
推荐指数
1
解决办法
2794
查看次数