【发布时间】:2020-11-23 12:03:43
【问题描述】:
我在发送填写的消息后尝试清空一个文本字段。消息被发送到数据库,但之后它并没有清空它。
文本字段:
<FlexboxLayout class="text-send">
<TextField
v-model="newMessage"
id="try"
class="body text-field"
width="70%"
@returnPress="onSendMessage()"
></TextField>
<Button
class="btn-secondary btn-design btn-next fas"
text.decode=">"
width="10%"
@tap="onSendMessage()"
/>
</FlexboxLayout>
发送消息代码:
onSendMessage() {
if (this.newMessage != "") {
let currentDate = Date()
firebase
.push("/messages/" + this.chatId, {
message: this.newMessage,
sender: this.getUserID,
timestamp: currentDate,
})
.then(function (result) {
console.log("created key: " + result.key);
});
}
this.newMessage = ""
},
this.newMessage = "",应该清除数据,但是没有用。
【问题讨论】:
-
尝试在你的.then中移动this.newMessage = ''或者在你清除后记录新消息的结果请进一步调查
标签: vue.js nativescript textfield