【发布时间】:2020-09-07 05:40:34
【问题描述】:
我正在尝试在我的模板视图中显示 Twilio 数据,列出使用 Twilio API 为我的帐户发送的所有消息。这一切都在 Nativescript-Vue 中。我的代码是这样的
<template>
<Page>
<ActionBar title="API TEST/>
<ScrollView>
<StackLayout>
<StackLayout :key="message.sid" v-for="message in myMessages">
<Label :text="message.body" />
<Label :text="message.from" />
<Label :text="message.to " />
</StackLayout>
</StackLayout>
</ScrollView>
</Page>
</template>
<script>
const Twilio = require('twilio');
const client = new Twilio("[my accountSid]","[my authToken]");
export default {
data() {
return {
myMessages: []
}
},
created() {
this.getList();
},
methods:
{
getList() {
client.messages
.list()
.then(messages => messages.forEach(m => this.myMessages.push(m))
)
.catch(err => console.error(err));
}
}
}
</script>
当我运行 tns run android 时出现以下错误
System.err: An uncaught Exception occurred on "main" thread.
System.err: Unable to create application com.tns.NativeScriptApplication:com.tns.NativeScriptException: Error calling module function
System.err: TypeError: Cannot read property 'split' of undefined
System.err: File: (file:///node_modules\pbkdf2\lib\default-encoding.js:6:47)
提前感谢您的帮助!
【问题讨论】:
-
我不认为这个包与 {N} 兼容,只有 CommonJS 模块适用于 {N} 运行时。
标签: node.js vue.js twilio nativescript nativescript-vue