passing parameter/input data to custom elements in DART

后端 未结 3 852
天命终不由人
天命终不由人 2021-01-24 16:28

I created a custom element, and want to send data / parameters to it:

my element code is:

   class SaveBtn         


        
3条回答
  •  执笔经年
    2021-01-24 16:56

    You can simply add a new constructor for this that sets the data-name attribute too:

    class SaveBtn {
      // ...
      factory SaveBtn(String label) {
        var btn = new Element.tag(tag);
        btn.setAttribute('data-name', label); // Set properties/call methods here
        return btn;
      }
      // ...
    }
    

提交回复
热议问题