Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import file dynamically in vue js

Below code which works for me

var Index = require('./theme/dir1/index.vue');

But I want to use It like this,

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

Which is not working for me, is there any way to make that fix.,

like image 883
Vishal Dodiya Avatar asked Feb 04 '23 18:02

Vishal Dodiya


1 Answers

Try this, it should work:

var Index = require(`./theme/${variable}/index.vue`);
like image 128
Mayank Shukla Avatar answered Feb 07 '23 06:02

Mayank Shukla