1.新建公共模板实例:
module.exports = {
secret: 'abcdefg',
getVersion: function(){
return '1.0.0'
}
}
2.调用公共模板的值
//uniCloud-aliyun\cloudfunctions\use-common\index.js
//云函数use-common
//需要设置管理公共模块依赖—hello-common
'use strict';
const {
secret,
getVersion
} = require('hello-common')
exports.main = async (event, context) => {
let version = getVersion()
console.log("secret: " + secret);
console.log("version: " + version);
return {
secret,
version
}
};