1๐
โ
You can import the whole namespace, then iterate over the keys you want:
import * as elementUI from 'element-ui';
const props = ['Row', 'Col', 'Form', 'FormItem', 'Icon', 'Input', 'Tooltip', 'Image', 'Button', 'Dialog'];
for (const prop of props) {
// do something with elementUI[prop]
}
If you want to iterate over every property, rather than only a select few, you can use Object.entries
instead:
import * as elementUI from 'element-ui';
for (const [key, value] of Object.entries(elementUI)) {
// do something with key and value
}
0๐
You could use wild card
import and then use for in
to iterate.
import * as objects from 'element-ui'
for(const key in objects) {
// do something here
}
-1๐
you mean like this?
import { Row, Col, Form, FormItem, Icon, Input, Tooltip, Image, Button, Dialog } as objects from 'element-ui'
objects.forEach(object => {
// do something here
})
Source:stackexchange.com