var tabPage = [{ text: '首页', iconPath: '../../assets/icon/index.png', selectedIconPath: '../../assets/icon/index.png', url: '../../pages/index/index', }, { text: '预约', iconPath: '../../assets/icon/appointment.png', selectedIconPath: '../../assets/icon/appointment.png', url: '../../pages/appointment/appointment', }] var api = { monitor: { host: '192.168.12.168', port: 3321, prefix:'v1/Monitor' } } var appCode = 1 module.exports = { tabPage: tabPage, api: api, appCode: appCode }
|
使用的时候
import { config } from '../../config/config.js' ; |
reqJsApi.get(`${config.api.monitor.prefix}/GetMonitorRealListData?basicSensorID=${id}`).then(res => { resolve(res); }); |
鼠标点到config,可以查看到很多属性,这时候是有api这个属性的
但是鼠标移动到api时,api显示undefind,这是什么原因呢?
如果是这样
module.exports = {
tabPage: tabPage,
api: api,
appCode: appCode
}
应该这样
import config from'../../config/config.js';
config才会有 config.api、config.tabPage、config.appCode
是 import config 不是import { config }