nvue 多個text超出自動換行


使用 組件 rich-text(nvue 專有) 富文本

<view class="bottom-msg-area lst">
            <scroll-view class="msg-area-scroll" scroll-y="true" scroll-with-animation
                :scroll-into-view="scrollIntoView">
                <view class="">
                    <text class="pingtai-tips">{{broadcastData.admin_info}} </text>
                    <text class="zhubo-tips">{{broadcastData.mer_info}}</text>
                </view>
                <view v-for="(item,i) in historyChat" :id="'danmu'+item.reply_id" :key="i">
                    <view class="listview" >
                        <!-- <text class="lin-msg-name">{{item.user.nickname}}:</text>
                        <text class="lin-msg-content">{{item.comment}}</text> -->
                        <rich-text :nodes="richNodes(item)"></rich-text>
                    </view>
                </view>
            </scroll-view>
        </view>


// js 邏輯 ( h5 )
richNodes(item) {
                return [
                    {
                        name: 'div',
                        attrs: {
                            class: 'div-rich-nickname',
                            style: 'color: #50c76f;display: contents;'
                        },
                        children: [
                            {
                                type: 'text',
                                text: item.user.nickname+''
                            }
                        ]
                    },
                    {
                        name: 'div',
                        attrs: {
                            class: 'div-rich-comment',
                            style: 'color: #fff;display: contents;'
                        },
                        children: [
                            {
                                type: 'text',
                                text: item.comment
                            }
                        ]
                    }
                ]
            }


 //( app )
richNodes(item) {
                return [{
                    children: [{
                            type: 'text',
                            attrs: {
                                class: 'lin-msg-name'
                            },
                            text: item.user.nickname + ''
                        },
                        {
                            type: 'text',
                            attrs: {
                                class: 'lin-msg-content'
                            },
                            text: item.comment
                        }
                    ]
                }]
            }


//樣式
.listview {
        padding: 6rpx 10rpx;
        margin: 10rpx 0;
        border-radius: 10rpx;
        background-color: rgba(0, 0, 0, 0.3);
    }
    .lin-msg {
        font-size: 22rpx;
        flex-direction: row;
    }
    .lin-msg-name {
        font-size: 26rpx;
        color: #50c76f;
        /* 可能是組件 rich-text 的問題,有默認的白色背景顏色,這里要給透明*/
        background-color: rgba(0, 0, 0, 0);
    }
    .lin-msg-content {
        font-size: 26rpx;
        color: #FFFFFF;
        background-color: rgba(0, 0, 0, 0);
    }

 

 

 

可以參考:https://www.cnblogs.com/robot666/p/14987404.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM