programing

각도2:잡히지 않음(약속):구성 요소에서 평가!에 대한 견적이 지원되지 않습니다.

starjava 2023. 7. 11. 21:23
반응형

각도2:잡히지 않음(약속):구성 요소에서 평가!에 대한 견적이 지원되지 않습니다.

입력 매개 변수가 있는 구성 요소가 있습니다.

import {Component,Input} from '@angular/core';

@Component({
    selector: 'comment' ,
    template: `    
        <div class="col-lg-6 col-md-6 col-xs-6 thumb">
            <div class="post-owner">
                <div class="media">
                    <div class="media-left">
                        <a href="#">
                          <img class="media-object rounder" src=imageURI >
                        </a>
                    </div>
                </div>
            </div>
        </div>`
})

export class CommentCompoent{
    @Input() imageURI="";
}

상위 구성 요소에서 다음과 같은 이미지 경로를 전달했습니다.

<comment [imageURI]='image_path'></comment>

문제는, 제가 그것을 실행할 때, 그것이 다음과 같이 불평한다는 것입니다.

EXCEPTION: Error: Uncaught (in promise): Quotes are not supported for evaluation!

그럼 어떻게 해야 하나요?

업데이트: 제거하면 정상적으로 작동합니다.[imageURI]='image_path'상위 구성요소에서, 그리고 그것은 나머지 구성요소를 완벽하게 보여줍니다.

변경해야 합니다.comment상위 구성 요소의 태그:

<comment [imageURI]="image_path"></comment>

템플릿 바인딩을 할당할 때 따옴표를 사용하지 마십시오.다음과 같은 문자열 형식 지정에만 사용합니다.

<comment [imageURI]="'path/to/image.jpg'"></comment>

이 오류를 검색하는 사람: 오류는 유용한 정보를 포함하지 않으며 다양한 이유로 인해 발생할 수 있으므로 HTML만 보고 파악하는 것은 불가능했습니다.하지만 브라우저에 로드된 각진 파일에 중단점을 넣으면(나의 경우)compiler.umd.js행 11702, 의 expression_sys.ts 참조@angular/compiler모듈, 라인 395, 함수visitQuote()이는 예외를 발생시키는 것입니다)를 드릴로 뚫을 수 있습니다.ast라는 속성을 가진 매개 변수location그리고.uninterpretedExpression어떤 성분과 표현식이 원인인지 범위를 좁히는 데 도움이 됩니다.저의 경우에는 그것이 곱슬곱슬한 교정기가 없었습니다.ngClass매개 변수

답을 받았습니다.이 정보는 상위 구성 요소로 돌아갑니다.올바른 형식은

<comment [imageURI]=image_path></comment>
export class SinglePictureComponent{
    username='Salman kkk';
    profile_pic="https://scontent-arn2-1.cdninstagram.com/t51.2885-19/s150x150/13743117_1060048037418472_411027981_a.jpg";
    comment="I love you";
}

그런 다음 속성을 설정합니다.

 <comment [username]=username   [comment]=comment [imageURI]=profile_pic></comment>

저도 다음과 같은 오류에 직면했습니다.

enter image description here

오류가 발생한 HTML 코드는 다음과 같습니다.

<div class="container">
  <span class="value">{{action.progress}}</span>
  <div class="wrap">
    <div class="bar" style="{{width:action.progress}}"></div>
  </div>
</div>

고정 코드: 아래 솔루션이 저에게 효과가 있었습니다.액션은 다음에서 발생합니다..ts스타일에 맞는 파일[ngStyle]아이템 가치를 직접 전달할 수 있습니다.

<div class="container">
  <span class="value">{{action.progress}}</span>
  <div class="wrap">
    <div class="bar" [ngStyle]="{width:action.progress}"></div>
  </div>
</div>

언급URL : https://stackoverflow.com/questions/38855890/angular2-uncaught-in-promise-quotes-are-not-supported-for-evaluation-in-the

반응형