小编Usr*_*Usr的帖子

离子3 - 显示圆形图像

我正在尝试在页面顶部设置圆形图像(如个人资料页面).图像是矩形的,大约300x200.我试过这些方法:

1)使用Ion-Avatar标签

2)使用Ion-Image标签,在scss中设置边框半径

这些方法都不起作用.图像只是在灰色圆圈内显示平方(并最终收缩):

在此输入图像描述

有什么建议?

html css circleimage ionic3

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

错误 使用 MatTableExporter 时没有将“exportAs”设置为“matTableExporter”的指令

文档示例中,我尝试使用 mat 表导出器,如下所示:

<ng-container>
    <mat-card class="mat-card py-0">
        <mat-card-header class="label">
          <ng-container>
            <mat-card-title>{{titoloTabella}}</mat-card-title> 
            <button mat-button class="align-right" (click)="changeClass()">
              <mat-icon [ngClass]="(rotate)?'rotate':'no-rotate'">keyboard_arrow_down</mat-icon>
              </button>
          </ng-container>
          </mat-card-header>
  <table mat-table  matSort [dataSource]="dataSource" matTableExporter #exporter="matTableExporter">
    <ng-container *ngFor="let header of tableConfiguration.tableHeaders; let i = index" matColumnDef="{{ header.headerId }}"> 
      <th mat-header-cell mat-sort-header *matHeaderCellDef>{{ header.headerName }}</th> 

      <td mat-cell *matCellDef="let row" > {{ row[header.headerId] }} </td> 

      <ng-container *ngIf="i == 0 && header.isJoinable == 'no'">
          <td mat-footer-cell *matFooterCellDef>TOTALE</td>
      </ng-container>
      <ng-container *ngIf="i > 0">    
          <td mat-footer-cell *matFooterCellDef>{{ tableFooter[header.headerId] }}</td>
    </ng-container>
    </ng-container>
    <tr mat-header-row …
Run Code Online (Sandbox Code Playgroud)

angular angular7 mat-table

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

离子3 - 运行时错误函数未定义 - ReferenceError:函数未在HTMLButtonElement.onclick中定义

我有一个按钮,我为onclick属性定义了doLogout函数,但每次单击该按钮时都会显示以下错误:

Runtime Error function not defined - ReferenceError: function is not defined at HTMLButtonElement.onclick
Run Code Online (Sandbox Code Playgroud)

代码非常简单,我在其他页面中使用它,正确调用该函数.这是我的HTML文件:

<ion-header>  
  <ion-navbar>
    <ion-title>Logout</ion-title>
  </ion-navbar>
</ion-header>

<ion-content>
  <div padding>
  <button ion-button block onclick="doLogout()">Logout</button>
 </div>  
   </ion-content>
Run Code Online (Sandbox Code Playgroud)

这是ts文件:

export class LogoutPage {

  constructor(public navCtrl: NavController, public navParams: NavParams,
  public api : Api) {
  }


  doLogout(){
       //does something
  }

}
Run Code Online (Sandbox Code Playgroud)

html typescript ionic2 ionic3 angular

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

单击按钮后,离子3从ion-textarea获取文本

我有一个ion-textarea用户可以写一些内容,我想在点击一个按钮后得到这个文本.
这是html:

<ion-row>
    <ion-item>
        <ion-textarea [(ngModel)]="myInput" (ionInput)="getItems($event)" placeholder="New Info"></ion-textarea>
    </ion-item>
</ion-row>
Run Code Online (Sandbox Code Playgroud)

<button ion-button class="card-button" color="secondary" 
 (click)="addInfo()"> <ion-icon name="add-circle" class="icona-bottone"></ion-
 icon>Add Info</button>
Run Code Online (Sandbox Code Playgroud)

我已经尝试在我的.ts文件中执行此操作:

getItems(textarea) {
    // set q to the value of the textarea
    var q = textarea.srcElement.value;
    this.textSearch = q;
}
addInfo(){
    console.log("You wrote " + this.textSearch)
}
Run Code Online (Sandbox Code Playgroud)

但它打印出"你写的undefined".将文本作为字符串并使用它的正确方法是什么?

textarea typescript ionic-framework ionic3 angular

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

Leaflet-marker 单击事件工作正常,但回调函数中未定义该类的方法

我正在使用以下代码click为某些传单标记(其中我不知道先验数字)的事件添加回调函数:

newArray.forEach(p => {
  let marker = L.marker(latLng).on('click', this.markerClick).addTo(newMap)
  marker.bindPopup(content)
  marker.addTo(newMap)
  marker.openPopup()
})
Run Code Online (Sandbox Code Playgroud)

在类中有markerClick执行此操作的函数:

markerClick(e) {
  console.log("Inside marker click " + e.latlng.lat + "  " + e.latlng.lng)
  this.displayError("You clicked on the marker")
}
Run Code Online (Sandbox Code Playgroud)

console.log正在打印的正确的价值观latlng标记,但是打电话时displayError运行时引发错误说:

this.displayError 不是函数

这是一个在类中声明的函数,我用来根据我的需要显示带有自定义消息的祝酒词。这是代码:

displayError(messageErr: string) {
  let toast = this.toastCtrl.create({
    message: messageErr,
    duration: 3000,
    position: 'top'
  });
  toast.present();
}
Run Code Online (Sandbox Code Playgroud)

为什么说那不是函数?

编辑:它不仅仅是displayError,类的每个函数都给出了这个消息。

javascript gis onclick leaflet ionic-framework

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

带有多个选项的 mat-select 中的样式复选框

我有一个 mat-select 与该multiple选项一起使用(请参阅文档中的此示例)。
我想设置复选框被选中时的颜色样式(默认情况下为蓝色)。
所以从这个:

在此处输入图片说明

我需要得到这个:

在此处输入图片说明

但我不知道我应该使用哪个 css 选择器/规则。
通常对于复选框,我会使用这个:

/deep/.mat-checkbox-checked.mat-accent .mat-checkbox-background, .mat-checkbox-indeterminate.mat-accent .mat-checkbox-background {
    background-color: #A5C73C;
}
Run Code Online (Sandbox Code Playgroud)

但选项不被视为复选框。

HTML :

<mat-form-field>
  <mat-select placeholder="Toppings" [formControl]="toppings" multiple>
    <mat-option *ngFor="let topping of toppingList" [value]="topping">{{topping}}</mat-option>
  </mat-select>
</mat-form-field>
Run Code Online (Sandbox Code Playgroud)

angular-material angular angular7

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

CSS在同一行中的两个跨度或div都在一个div中

我试图达到这个结果:

在此处输入图片说明

但是我无法用数字正确定位两个 div(或跨度)。

我试过使用两个跨度inline-block来显示,这样:

HTML:

<div class="row">
    <mat-form-field class="col">
        <mat-label>{{ 'REPORTISTICA_UFFICI_QUALITA.select_report' | translate }}</mat-label>
        <mat-select (selectionChange)="onChangeSelection($event)" [(value)]="actualView">
          <mat-option *ngFor="let report of mappaReport" [value]="report.value">
            {{report.description}}
          </mat-option>
        </mat-select>
    </mat-form-field>
    <div class="col-dettagli"  *ngIf="actualView == 'cooperative' ">
      <span class="col-interventi-attivita" >
      <mat-label>Interventi</mat-label>
          <input matInput type="text"
                  placeholder="{{ totaleInterventi }}" [readonly]="true">
      </span>
      <span class="col-interventi-attivita">
              <mat-label>Attivita</mat-label>
          <input matInput type="text"
                  placeholder="{{ totaleAttivita }}" [readonly]="true">
                  </span>
    </div>
  </div>
Run Code Online (Sandbox Code Playgroud)

CSS:

.col {
  width: 25%;
}

.col-dettagli{
  text-align: right;
}

.col-interventi-attivita{
  display: inline-block;
}
Run Code Online (Sandbox Code Playgroud)

但这不正确,我明白了:

在此处输入图片说明

然后我尝试将 CSS 更改为:

.col { …
Run Code Online (Sandbox Code Playgroud)

html css angular

2
推荐指数
1
解决办法
296
查看次数

Typescript String.format 不存在

我有一个字符串常量,我必须替换两个单词,如下所示:

public static readonly MY_STRING: string = 'page={0}&id={1}';
Run Code Online (Sandbox Code Playgroud)

0和1必须用其他字符串替换。我在不同的答案中读到过有关 String.format 的内容,他们建议提供这样的实现:

if (!String.prototype.format) {
  String.prototype.format = function() {
    var args = arguments;
    return this.replace(/{(\d+)}/g, function(match, number) { 
      return typeof args[number] != 'undefined'
        ? args[number]
        : match
      ;
    });
  };
}
Run Code Online (Sandbox Code Playgroud)

但当我String.format这样做时它告诉我

Property 'format' does not exist on type 'String'
Run Code Online (Sandbox Code Playgroud)

在这种情况下使用字符串插值/替换的正确方法是什么?对于格式我会做这样的事情:

 MY_STRING.format(page, id)
Run Code Online (Sandbox Code Playgroud)

我怎样才能实现这个目标?

string-interpolation typescript

2
推荐指数
1
解决办法
5898
查看次数

尝试打开没有关联输入的 MatDatepicker

我定义了这个 MatDatePicker:

 <input #creatoDal matInput [matDatepicker]="creatoDal"
                            (focus)="creatoDal.open()" readonly>
                        <mat-datepicker-toggle matSuffix [for]="creatoDal"></mat-datepicker-toggle>
                        <mat-datepicker #creatoDal></mat-datepicker>
Run Code Online (Sandbox Code Playgroud)

在我看来,我已经正确绑定了引用,但是当单击日期选择器时,它不会打开,并且会出现以下错误:

错误:尝试打开没有关联输入的 MatDatepicker。在 MatDatepicker.push../node_modules/@angular/material/esm5/datepicker.es5.js.MatDatepicker.open

angular angular7 mat-datepicker

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

Haskell没有(Eq Digit)实例使用==在表达式中:x == One

data Digit = Zero | One
convBNum :: [Digit] -> Int
convBNum [] = 0
convBNum (x:xs)
  | x == One = 2^length xs + convBNum xs
  | otherwise = convBNum xs
Run Code Online (Sandbox Code Playgroud)

这是将二进制数转换为int的简单函数的代码; 当我编译它时,它给了我这个错误:

no instance for (Eq Digit) arising from a use of == 
In the expression: x == One
Run Code Online (Sandbox Code Playgroud)

如果我理解得很好,也读了其他问题,问题是x不能是任何类型,但我无法理解如何解决这个问题以及如何使用Eq约束.

binary haskell

0
推荐指数
2
解决办法
291
查看次数

Typescript 将字符串转换为 Map

我有这个字符串(称为 currentExecution.variables):

{executionid=0c3246fb37e65e3368c8c4f30000016ab593bec244daa8df, timeout=10000}
Run Code Online (Sandbox Code Playgroud)

我需要将其转换为地图,以便我可以处理条目,但我很难做到这一点。我尝试按照此答案将其转换为键值对集。首先,我将 = 替换为 : 并将 { 或 } 替换为空格,然后根据答案将其拆分:

newString.split(/,(?=[^,]+:)/).map(s => s.split(': '));
Run Code Online (Sandbox Code Playgroud)

但我没有得到正确的结果,而且我在没有地图的情况下陷入困境。少了什么东西?或者有更好/更快的方法来做到这一点?

javascript arrays string split

0
推荐指数
1
解决办法
6278
查看次数