下面是适合我的代码
var Index = require('./theme/dir1/index.vue');
但我想这样使用它,
var path = './theme/'+variable+'/index.vue';
var Index = require(path);
这对我不起作用,有什么办法可以解决这个问题。
最佳答案
试试这个,它应该工作:
var Index = require(`./theme/${variable}/index.vue`);
关于javascript - 在vue js中动态导入文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43133751/