@input="inputHandler" adjust-position="false" cursor-spacing="20" always-embed show-confirm-bar="false" cursor="inputCursor" focus="inputFocus" @blur="onBlurHandler"
@focus="onFocusHandler" disable-default-padding="true" @keyboardheightchange="onKeyboardHeightChangeHandler"
confirm-type="send"></textarea>
</view>
</view>
</template>
<script>
export default {
data() {
return {
text: 'Hello',
inputCursor: 0,
inputFocus: false,
}
},
onLoad() {
},
methods: {
sendMessage() {
console.info('----sendMessage----===------')
},
inputHandler(e) {
console.info('----inputHandler----===------')
this.text = e.detail.value;
},
onBlurHandler() {
console.info('----onBlurHandler----===------')
},
onFocusHandler() {
console.info('----onFocusHandler----===------')
},
onKeyboardHeightChangeHandler(e) {
console.info('----onKeyboardHeightChangeHandler----===------', e)
}
}
}
</script>
4 个回复
最佳回复
DCloud_UNI_yuhe
目前鸿蒙上 adjust-position 会与 show-confirm-bar 冲突,暂时可以通过在鸿蒙平台去掉 show-confirm-bar 来解决
DCloud_UNI_yuhe
我刚才确认了一下这个应该是支持的,你可以测试一下 :adjust-position="false"
RongCloud (作者)
那有支持计划吗?或者有什么其他方式控制吗?
2025-09-02 14:50
RongCloud (作者)
我就是设置了发现不好用,您那边的测试代码可以给我提供下吗?而且这边发现在手动点击收起后就不自动顶起了。但是如果是失去焦点这种在得到焦点还是会自动顶起。并且会多一个安全区的高度
2025-09-02 15:05
DCloud_UNI_yuhe
回复 RongCloud:
2025-09-02 15:19
RongCloud (作者)
我现在就是想关闭掉自动弹起,关不掉。而且自动弹起会多一个安全区的高度,这个要怎么处理,是哪个配置影响的吗
DCloud_UNI_yuhe
你项目的 harmony-configs 下是不是有 oh-packages?
2025-09-02 15:18
RongCloud (作者)
回复 DCloud_UNI_yuhe: 没有的 只有 module.json5 和 string.json 两个文件
2025-09-02 15:45
DCloud_UNI_yuhe
回复 RongCloud: 麻烦你把上面的代码运行效果录个视频看看,对比一下加了false和不加false的效果
2025-09-02 15:49
RongCloud (作者)
@confirm="sendMessage"
@input="inputHandler"
always-embed
@blur="onBlurHandler"
@focus="onFocusHandler"
@keyboardheightchange="onKeyboardHeightChangeHandler"
confirm-type="send"></textarea>
</view>
</view>
</template>
<script>
export default {
data() {
return {
text: '11',
inputCursor: 0,
inputFocus: false,
}
},
onLoad() {
</script>
<style lang="scss">
.rc-input-container {
z-index: 100;
position: fixed;
left: 0;
right: 0;
bottom: 0;
box-sizing: border-box;
padding: 9px 11px 9px;
padding-bottom: calc(env(safe-area-inset-bottom));
padding-bottom: calc(constant(safe-area-inset-bottom));
}
</style>
我使用你提供的代码示例 true false 会有区别,但是感觉有 bug 会出现偶现滚动条滑动不到底部的情况。但是代码里面不知道是不是因为用了浮动布局,导致 :adjust-position="false" 没有效果,
2025-09-02 16:12
DCloud_UNI_yuhe
回复 RongCloud: 有试过其它平台吗?效果一致吗?
2025-09-02 16:51
RongCloud (作者)
回复 DCloud_UNI_yuhe: 其他平台没有问题。
2025-09-02 17:00
RongCloud (作者)
我代码里有逻辑控制 :adjust-position="false" 后,整个输入栏的弹起高度由 @keyboardheightchange 事件返回的高度做适应。
但是看视频里面的设置 false 后并没有效果,我又通过 @keyboardheightchange 事件 弹起了高度。但是当我点击手动收起后,效果正常了。但是只要不点击手动收起就是会得到焦点自动跟随。