!2402 【Sample】code/Solutions/IM/Chat 输入框文字无法清空

Merge pull request !2402 from wenxusun/0230chat
This commit is contained in:
openharmony_ci 2023-03-30 11:24:18 +00:00 committed by Gitee
commit c31769449a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 13 additions and 12 deletions

View File

@ -1,7 +1,7 @@
/node_modules
**/node_modules
/local.properties
/.idea
**/build
/.hvigor
/package-lock.json
/entry/package-lock.json
**/package-lock.json
**/.preview

View File

@ -11,4 +11,4 @@
"repository": {},
"version": "1.0.0",
"dependencies": {}
}
}

View File

@ -37,7 +37,7 @@ struct ChatDetailPage {
msg2 = new TextMessage("我是好友消息2")
tdate = new Date()
megbody = new MessageBase("1", this.user1, this.user2, this.msg2, 1, this.tdate.getSeconds())
keyboartStr: string
@State keyboardStr: string = ''
private chatDetailData = new ChatDetailData()
private scroller: Scroller = new Scroller()
@State wantParams: WantModel = new WantModel() // want的自定义参数
@ -71,7 +71,7 @@ struct ChatDetailPage {
}
.key('moreBtn')
.onClick(() => {
router.push({
router.pushUrl({
url: "pages/ChatNewsPage",
params: { NAME: router.getParams().chatName, IMAGEID: router.getParams().chatId }
})
@ -100,22 +100,23 @@ struct ChatDetailPage {
Image($r('app.media.chatting_setmode_voice'))
.height(20)
.width(20)
TextInput({ placeholder: "", text: "" })
TextInput({ placeholder: "", text: this.keyboardStr })
.key('bottomTextInput')
.height(40)
.width('80%')
.enterKeyType(EnterKeyType.Send)
.onChange((value: string) => {
this.keyboartStr = value
this.keyboardStr = value
})
.onSubmit((enterKey) => {
this.tdate = new Date()
let msg = new TextMessage(this.keyboartStr)
let msg = new TextMessage(this.keyboardStr)
let msgBody = new MessageBase(this.chatDetailData.totalCount()
.toString(), this.user1, this.user2, msg, 1, this.tdate.getSeconds())
this.chatDetailData.pushData(msgBody)
this.msgLength = this.chatDetailData.totalCount()
this.scroller.scrollToIndex(this.msgLength - 1)
this.keyboardStr = ''
})
Image($r('app.media.chatting_expression'))
.key('chatExpression')

View File

@ -1,6 +1,6 @@
// @ts-nocheck
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -30,7 +30,7 @@ export struct DiscoverPage {
SettingItemView({ image: $r('app.media.find_friends'), text: "聊天社区" })
}
.onClick(() => {
router.push({
router.pushUrl({
url: 'pages/FriendsMomentsPage'
})
})

View File

@ -15,4 +15,4 @@
"@ohos/hvigor-ohos-plugin": "1.3.1",
"@ohos/hvigor": "1.3.1"
}
}
}