【发布时间】:2018-11-23 02:15:09
【问题描述】:
我有一个div 和ion-input #fileInput type="file" accept="image/*" id="fileInput" [(ngModel)]="imageFilePath" (ionChange)="imageFilePath_change($event)" ></ion-input>
如何使用div模拟点击ion-input组件?
我的html代码是:
<div (click) = "fileInput.click()">
<img src="assets/img/camera_button.png" [ngStyle]="{'position': 'fixed', 'top': '30vw', 'left': '32vw', 'height': '30px', 'color': '#0080FF'}">
<ion-input #fileInput type="file" accept="image/*" id="fileInput" [(ngModel)]="imageFilePath" (ionChange)="imageFilePath_change($event)" ></ion-input>
<span [ngStyle]="{'position': 'fixed', 'top': '32vw', 'left': '42vw', 'color': '#0080FF'}">{{ 'addMorePhotosBtn' | translate }}</span>
</div>
错误是:
TypeError: jit_nodeValue_20(...).click is not a function
【问题讨论】:
-
<ion-input (click) ...? -
不,我在 div 中模拟离子输入的点击
-
您的
#fileInput所以ion-input没有名为click的函数 -
为什么需要点击输入?为什么不直接从原来的点击事件处理器中调用组件方法呢?
-
请你写一个简单的例子好吗?