I html 파일에 다음과 같은 요소가 :Aurelia의 사용자 정의 요소에서 "readonly"를 바인드하는 방법은 무엇입니까?
<template class="range-slider time-slot">
<div>${duration}</div>
<input type="range" min.bind="min" max.bind="maxStart" step.bind="step" value.bind="value">
</template>
및 시간 슬롯 slider.ts :
<require from="_controls/time-slot-slider"></require>
<time-slot-slider id="zeitraum" min="0" max="24" length="4" value="4"
value.two-way="functionConfig.startTime" if.bind="functionConfig.isAutomatic === true"
readonly.bind="!mayFunctionTestEditTime"></time-slot-slider>
사용자 정의 요소 (시간 슬롯 slider.html) 여기
import { bindable, customElement } from 'aurelia-templating'
import moment from 'moment/moment'
import Moment = moment.Moment
@customElement('time-slot-slider')
export class TimeSlotSlider {
@bindable public min: number = 0.0
@bindable public max: number = 24.0
@bindable public step: number = 0.5
@bindable public value: number = 0.0
@bindable public length: number = 4.0
public get maxStart(): number {
return this.max - this.length
}
public get from(): Moment {
return TimeSlotSlider.numberToMoment(this.value)
}
....
그러나 읽기 전용 .bind이 작동하지 않습니다. 읽기 전용으로 바인딩하려고 시도했습니다.
@bindable readOnly: boolean
하지만 성공하지 못했습니다. 어떻게 해결할 수 있습니까?
나는 그것을했다. 그러나 나는이 경고를 받는다 : 'TimeSlotSlider'타입에서 'readonly'을 찾을 수 없다. – Sohrab
당신은'readonly' 대신'readOnly'를 작성했다. 대문자'O'를 주목하십시오. viewmodel에서'readOnly'를'readonly'로 변경하거나, 해당 컴포넌트를 사용하는 HTML에서'readonly.bind'를'read-only.bind'로 변경하십시오. –
soooooooo 많이 감사합니다. – Sohrab