小编Isl*_*med的帖子

Angular 12 - 类型错误:无法读取 null 的属性(读取“writeValue”)

Angular 12 - 类型错误:无法读取 null 的属性(读取“writeValue”)

我正在创建一个通用文本输入组件,在为项目提供服务时一切正常,但在构建的项目中我收到此错误:

类型错误:无法读取 null 的属性(读取“writeValue”)

HTML:

<div class="p-field">
    <label>{{label}} <span class="p-error">{{checkRequired(ngControl.control) ? '*' : ''}}</span></label>
    <input class="full-width" [type]="type" pInputText [formControl]="ngControl.control">

    <small *ngIf="ngControl.control.touched && ngControl.control.errors?.required" class="p-error">{{label}} is required</small>


    <small *ngIf="ngControl.control.errors?.minlength" class="p-error">
        {{label}} must be at least {{ngControl.control.errors.minlength['requiredLength']}}
    </small>

    <small *ngIf="ngControl.control.errors?.maxlength" class="p-error">
        {{label}} must be at most {{ngControl.control.errors.maxlength['requiredLength']}}
    </small>
    <small *ngIf="ngControl.control.errors?.email" class="p-error">
        This email is not valid
    </small>

    <small *ngIf="ngControl.control.errors?.isMatching" class="p-error">Passwords do not match</small>
</div>
Run Code Online (Sandbox Code Playgroud)

组件.ts

import { Component, Input, OnInit, Self } from '@angular/core';
import {AbstractControl, …
Run Code Online (Sandbox Code Playgroud)

angular angular-reactive-forms angular-controlvalueaccessor

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

更新 gradle,找不到参数的方法compile()

我正在尝试将离子电容器项目的 gradle 更新到版本 7.0.1。我不断收到此错误

Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method compile() for arguments [{name=barcodescanner-release-2.1.5, ext=aar}] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Run Code Online (Sandbox Code Playgroud)

我搜索了很多来解决这个问题,但所有可能的修复都表明我需要更改“app/build.grade”中的“编译”方法“实现”,但实际上该文件不包含“编译”方法!

apply plugin: 'com.android.application'

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    defaultConfig {
        applicationId "****"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 10
        versionName "1.8"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        aaptOptions {
             // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
             // Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
            ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    } …
Run Code Online (Sandbox Code Playgroud)

android gradle ionic-framework

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