我在TypeScript中输入了一个拼写错误,这是在代码审查期间被选中的.
我用someArray.indexOf[someObject]而不是someArray.indexOf(someObject).
我希望IDE /编译器出错.相反,没有引发错误,结果只是未定义.
有谁能解释一下?
我有一个 Ionic 5/Angular 应用程序,它使用 Ionic Native Camera 插件来拍照并裁剪图像。在我更新到 Android 11(使用 note 10 plus)之前,该功能一直运行良好。更新后,裁剪时抛出以下错误:无法保存裁剪后的图像 - 访问被拒绝。
TS代码:
takePicture() {
this.androidPermissions.requestPermissions([this.androidPermissions.PERMISSION.READ_EXTERNAL_STORAGE,
this.androidPermissions.PERMISSION.WRITE_EXTERNAL_STORAGE]);
const options: CameraOptions = {
quality: 100,
targetHeight: 1920,
targetWidth: 1080,
sourceType: 1, // CAMERA
destinationType: 0, // DATA_URL
encodingType: this.camera.EncodingType.JPEG,
correctOrientation: true,
allowEdit: true
};
this.camera.getPicture(options).then((imageData) => {
// Persist image data
});
}
Run Code Online (Sandbox Code Playgroud)
应用程序在其他设备上运行良好。还检查了我的应用程序、图库应用程序和照片编辑器应用程序是否具有存储和相机权限。我可以拍照,裁剪器会打开 - 点击“完成”后,会显示“访问被拒绝”消息,紧接着会显示“无法保存裁剪后的图像”。
注意:我在另一台运行 Android 11 的设备上进行了测试,结果出现了相同的错误。
我使用的是 Ionic 7 和 Angular(材质)14。
我想在适用的字段标签中显示必填字段指示符 (*)。
在 Ionic 6 中,我通过在 ion-label 中添加 span 标签以及用于样式化的类来实现这一点,例如:
<ion-item>
<ion-label position="fixed">Title<span class="required-field-indicator">*</span></ion-label>
<ion-select formControlName="title">
<ion-select-option *ngFor="let title of titles" value="{{title}}">{{title}}</ion-select-option>
</ion-select>
</ion-item>
Run Code Online (Sandbox Code Playgroud)
然后我可以使用 CSS 更改指标的样式:
.required-field-indicator {
color: var(--ion-color-tertiary);
font-weight: bolder;
padding: 2px;
}
Run Code Online (Sandbox Code Playgroud)
我的字段将显示如下:
我现在已升级到 Ionic 7,根据文档 ( https://ionicframework.com/docs/api/select),ion-label不再适用于 ion-input 和 ion-select。相反,应该使用离子选择组件上的标签和标签放置属性,如下所示:
我相应地更新了我的代码:
<ion-item>
<ion-select label="Title" labelPlacement="fixed" formControlName="title" [required]="true">
<ion-select-option *ngFor="let title of titles" value="{{title}}">{{title}}</ion-select-option>
</ion-select>
</ion-item>
Run Code Online (Sandbox Code Playgroud)
但是,通过此更改,我无法再添加(除非我将其作为标签属性中的字符添加)或自定义所需的字段指示符符号。
如何在 Ionic 7 中添加我的指示器并设置其样式?
我已经设法在 ion-input 组件上使用 CSS 来做到这一点:
.required-indicator {
.label-text::after { …Run Code Online (Sandbox Code Playgroud) android ×1
angular ×1
css ×1
html ×1
ionic-native ×1
ionic5 ×1
ionic7 ×1
methods ×1
properties ×1
typescript ×1