Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/468.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在vue js中动态导入文件_Javascript_Reactjs_Meteor_Vue.js_Vuejs2 - Fatal编程技术网

Javascript 在vue js中动态导入文件

Javascript 在vue js中动态导入文件,javascript,reactjs,meteor,vue.js,vuejs2,Javascript,Reactjs,Meteor,Vue.js,Vuejs2,下面是适合我的代码 var Index = require('./theme/dir1/index.vue'); 但我想这样使用它 var path = './theme/'+variable+'/index.vue'; var Index = require(path); 这对我不起作用,有没有办法解决这个问题。,试试这个,它应该会起作用: var Index = require(`./theme/${variable}/index.vue`); @moáois变量是在前面定义的path

下面是适合我的代码

var Index = require('./theme/dir1/index.vue');
但我想这样使用它

var path = './theme/'+variable+'/index.vue';
var Index = require(path);

这对我不起作用,有没有办法解决这个问题。,

试试这个,它应该会起作用:

var Index = require(`./theme/${variable}/index.vue`);

@moáois变量是在前面定义的path@mo顺便说一句,我使用webpack作为依赖项管理器,但不需要大括号。哪个大括号,内部还是外部?你能显示你在使用什么吗?
var Index=require(`./theme/${variable}/Index.vue`)