Access a DOM element in Aurelia

后端 未结 5 1087
独厮守ぢ
独厮守ぢ 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:51

    As Rob suggested, use ref. For your example:

    view

    viewModel

    class ViewModel { 
    
        canDeactivate() {
            var form = this.myForm;
            // do stuffs
        }
    }
    

    For more information on the ref attribute, see here: http://aurelia.io/docs/binding/basics#function-references

提交回复
热议问题