App.js
Original
import x from 'project/a'
can it be
var project = 'a'
if(project == 'a')
{
import x from 'project/a'
}
else
{
import x from 'project/b'
}
or could it use
var project = 'a'
var filepath = '';
if(project == 'a')
{
filepath = 'project/a';
}
else
{
filepath = 'project/b';
}
import x from filepath
You could either import both and do the conditional:
import initProjectA
import initProjectB
if (condition) {
initProjectA()
} else {
initProjectB()
}
Or do dynamic imports:
import(module).then(importedModule => {
importedModule.default() // assuming you did `export default`
})
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.