postData为undefined, 无法通过require获得内容,检查过路径,数据暴露接口的写法都没问题,程序没有报错。
来源:18-2 使用require方法加载js模块儿文件

Neolu4ever
2018-10-22
Require部分:
var postData = require(’…/…/data/posts-data.js’)
数据接口部分:(exports.localData 参考的是官方文档描述的写法)
module.exports.localData = {
postList:localData
}
调试结果:
写回答
1回答
-
赚钱娶媳妇
2018-10-22
为什么不按照视频里的写法呢
module.exports = { postList: localData }
我印象里是可以用你这种写法的,但是取值的时候会多一层
postData.localData.postList
012018-10-23
相似问题