Access a DOM element in Aurelia

后端 未结 5 1062
独厮守ぢ
独厮守ぢ 2021-01-07 17:09

How would you go about accessing a DOM element in Aurelia? This is a broad and general question, but I have a feeling there are one or two preferred ways to do this. I have

5条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-07 17:58

    Another option; if your view-model is exposed as a @customElement, its DOM element can be injected in the constructor:

    @customElement
    @inject(Element)
    export class MyCustomElement {
        constrctor(element) {
            logger.info(element) // ==> 
        }
    }
    

提交回复
热议问题