说明,由于vscode在ts状态下没有自动导入js 的功能,特此写此篇文章来说明手动导包的方法
由于过于简单,即参考阿里大于老版本api导入的方法:
......
import SMSClient = require('@alicloud/sms-sdk');
......
export class SmsService {
sendSms() {
const sms: SmsReq = {
phone: '12345678901',
key: this.app.ali_key,
model: this.app.alert_MODE,
sign: this.app.sms_sign,
secrect: this.app.ali_secret,
};
// sendSms(sms);
const client = new SMSClient({
accessKeyId : sms.key,
secretAccessKey : sms.secrect});
client.sendSMS({
PhoneNumbers: sms.phone,
SignName: sms.sign,
TemplateCode: sms.model,
// tslint:disable-next-line:quotemark
TemplateParam: '{"content": "test"}',
}).then((res) => {
this.log.w('res', res);
}, (err) => {
this.log.e('err', err);
});
}
网友评论