Импортировать компонент из переменной pathname - PullRequest
0 голосов
/ 14 июня 2019

Мне нужно объединить строку, содержащую путь к файлу vue, и импортировать ее.

Я пробовал следующий код:

const electron = require('electron');
const fs = require('fs');
// let electron know which OS is used and get the right path, the path is different on each OS.
const userDataPath = (electron.app || electron.remote.app)
    .getPath('appData');

let import_path = userDataPath + '/Test.vue';

import test from import_path;

/src/renderer/router.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: Unexpected token (15:17)

  13 | let import_path = userDataPath + '/Test.vue';
  14 | 
> 15 | import test from import_path;

Как мне импортировать файл vue?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...