具体来说,我需要检索当前用户的HOME变量的值。但我希望答案通常适用于任何环境变量。
答案 0 :(得分:2)
public getTypes(vitalsModel) : Array<any> {
var vitals = _.get(vitalsModel, 'data');
if (_.isEmpty(vitals) || !_.isArray(vitals)) {
return [];
}
// the this pointer is valid
_.forEach(vitals, function (vital) {
let setting = _.get(vitalsModel, key);
// here the this pointer is null.
this.generalSettings.push(setting);
console.log(keys);
rows.push(keys);
loc++;
});
return rows;
}
检索环境变量system attribute "HOME"
的值。
该机制一般运作:
HOME