导入目录的索引文件无法正常运行

Connorelsea

application.js文件的以下内容报告未定义导入的“ home”。

import {home} from "./routes/index"
console.log(JSON.stringify(home, null, 4))

index.js的内容如下:

export * from "./home.js"

home.js的内容如下:

export const type = "GET"

export const route = "/"

export const middleware = [];

export const action = function(req, res) {
    res.send("Testing custom routes");
}

目录结构图如下:

目录

迈克·克拉克

您不会导出名为的任何内容home如果要附加所有内容,导出到名为的变量,home然后使用as

import * as home from './routes/index';

有关导入/导出的更多信息,请参见此处

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章