【发布时间】:2021-05-07 01:07:45
【问题描述】:
我正在尝试使用滑块控件将图像更改为灰度和棕褐色
这是我的html代码
<div class="card-body">
<input id="sepia" type="range" oninput="set(this, 'sepia');" value="0" step="0.1" min="0" max="1"> Sepia <span id="Amount_sepia">(0)</span><br/>
<input id="grayscale" type="range" oninput="set(this, 'grayscale');" value="0" step="0.1" min="0" max="1"> Grayscale <span id="Amount_grayscale">(0)</span><br/>
</div>
<img class="img-fluid" id="img_prev" src="{{actualImage}}" *ngIf="!this.showCropper" />
<image-cropper id="img_prev" class="imageclass" *ngIf="this.showCropper"
[autoCrop]="false"
[imageChangedEvent]="imageChangedEvent"
[maintainAspectRatio]="true"
[aspectRatio]="4 / 3"
[resizeToWidth]="256"
[cropperMinWidth]="128"
[onlyScaleDown]="true"
format="png"
(imageCropped)="imageCropped($event)"
(imageLoaded)="imageLoaded()"
(cropperReady)="cropperReady()"
(loadImageFailed)="loadImageFailed()" style="max-height:500px">
</image-cropper>
这是我的同款
public set(e,f){
document.getElementById('img_prev').style["filter"] = f+"("+e.value+")";
document.getElementById('Amount_'+f).innerHTML="("+e.value+")";
}
我遇到错误
(index):13 Uncaught ReferenceError: set is not defined
at HTMLInputElement.oninput ((index):13)
【问题讨论】:
-
set 是 javascript 中的保留字。你不能用它作为函数名..
标签: javascript angular typescript angular8