【发布时间】:2020-01-31 22:13:34
【问题描述】:
我的项目中有很多 viewchild 行。如何减少线路。有什么办法吗?
请帮忙找出解决办法。
app.component.ts:
@ViewChild('pRef') pRef: ElementRef;
@ViewChild('Ref') Ref: ElementRef;
@ViewChild('pR') pR: ElementRef;
@ViewChild('ef') ef: ElementRef;
@ViewChild('main') main: ElementRef;
@ViewChild('power') power: ElementRef;
@ViewChild('current') current: ElementRef;
@ViewChild('volt') volt: ElementRef;
@ViewChild('rm') rm: ElementRef;
@ViewChild('wire') wire: ElementRef;
@ViewChild('cable') cable: ElementRef;
@ViewChild('on') on: ElementRef;
@ViewChild('off') off: ElementRef;
@ViewChild('amp') amp: ElementRef;
@ViewChild('short') short: ElementRef;
@ViewChild('cap') cap: ElementRef;
【问题讨论】:
-
可以看这个链接(关于@ViewChildren,QueryList)netbasal.com/…
-
@Caro:很难理解..你能在 stackblitz 中编辑我的脚本吗?我的意思是任何示例演示
-
您能否在 stackblitz 上提供您的代码,看看您的 @ViewChild 是做什么用的?
标签: typescript angular6 angular7 angular8