How to call a jQuery function from Dart?

前端 未结 3 1320
灰色年华
灰色年华 2020-12-17 22:53

This is a typical situation in jQuery:

$(\".myClass\").myFunction({
    aKey: \'some value\'
});

H

相关标签:
3条回答
  • 2020-12-17 23:08

    You can use the build-in funcitons querySelector or querySelectorAll instead of the jQuery selector. So it would be:

    main(){   
        querySelector(".myClass").myFunction(){
            aKey: 'some value'
        } 
    }
    

    or for mulitple elements:

    main(){
        querySelectorAll(".myClass").myFunction(){
            aKey: 'some value'
        } 
    }
    
    0 讨论(0)
  • 2020-12-17 23:09

    How about use DQuery instead.

    DQuery is a porting of jQuery in Dart.

    0 讨论(0)
  • 2020-12-17 23:12

    You can do :

    main() {
      js.context.callMethod(r'$', ['.myClass'])
          .callMethod('myFunction', [new js.JsObject.jsify({'aKey': 'some value'})]);
    }
    
    0 讨论(0)
提交回复
热议问题