简体   繁体   中英

How to get applied/computed style of a dojo widget

I have a requirement where I need to get the computed/applied css style of a widget. I am using dojo widget. Is there way to identify the styles programmatically?

Use the dom-style module.

I'm assuming you're trying to get styles off the root node of your widget (specify if otherwise):

require(['dojo/dom-style','my/Widget'], function(domStyle, Widget) {

    var widgetInstance = new Widget();

    var integerWidthInPixels = domStyle.get(widgetInstance.domNode, 'width');

});

There's also the "domStyle.getComputedStyle" function, which despite the name probably isn't what you actually want. Look at the docs.

http://dojotoolkit.org/reference-guide/1.10/dojo/dom-style.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM