吕先森
吕先森
  • 发布:2021-11-22 14:48
  • 更新:2021-11-22 15:37
  • 阅读:1626

rich-text 里面 itemclick如何触发,怎么都触发不了

分类:nvue

nvue组件里

<rich-text :nodes="creatListNode(x)" :selectable="false" class="rich-text" @itemclick="test"></rich-text>  

结构

creatListNode(item){  
            let name = `{  
                name: 'a',  
                attrs: {  
                    class: 'name',  
                    style:'color: #4e5c7f;font-size: 36rpx;line-height: 48rpx;',  
                    href:'https://www.baidu.com/',  
                    pseudoRef:'1222'  
                },  
                children: [  
                    {  
                        type: 'text',  
                        text: '${item.nickname}'  
                    }  
                ]  
            },`;  
            let reply = item.parentId != '0'?`{  
                name: 'span',  
                attrs: {  
                    class: 'reply'  
                },  
                children: [  
                    {  
                        type: 'text',  
                        text: '回复'  
                    }  
                ]  
            },`:'';  
            let replyName = item.parentId != '0'?`{  
                name: 'a',  
                attrs: {  
                    class: 'name',  
                    style:'color: #4e5c7f;font-size: 36rpx;line-height: 48rpx;'  
                },  
                children: [  
                    {  
                        type: 'text',  
                        text: '${item.replyName}'  
                    }  
                ]  
            },`:'';  
            let colcon = `{  
                name: 'span',  
                children: [  
                    {  
                        type: 'text',  
                        text: ':'  
                    }  
                ]  
            }`  
            let content = ''  
            let loop = []  
            let first_arr = item.jugeContnet.split(/\#[\u4E00-\u9FA5]{1,3}\;/);  
            let emotions = item.jugeContnet.match(/\#[\u4E00-\u9FA5]{1,3}\;/g);  
            first_arr.forEach(i=>{  
                if(i===''){  
                    if(emotions.length){  
                        loop = loop.concat(eval(`[{  
                            name: 'img',  
                            attrs:{  
                                class:'img',  
                                src:'${emotionImgSrc(emotions.shift())}',  
                                style:'width:20px;height:20px'  
                            }  
                        }]`))  
                    }  
                }else{  
                    loop = loop.concat(eval(`[{  
                        name: 'span',  
                        children: [  
                            {  
                                type: 'text',  
                                text: '${i}',  
                                style:'color: #000;font-size: 36rpx;line-height: 48rpx;'  
                            }  
                        ]  
                    }]`))  
                }  
            })  
            return eval('['+name+reply+replyName+colcon+']').concat(loop)  
        }

有a标签,有href,有pseudoRef,但是itemclick无法触发

2021-11-22 14:48 负责人:无 分享
已邀请:
吕先森

吕先森 (作者)

数组结构如下:
[{
"name": "a",
"attrs": {
"class": "name",
"style": "color: #4e5c7f;font-size: 36rpx;line-height: 48rpx;",
"href": "https://www.baidu.com/",
"pseudoRef": "1222"
},
"children": [{
"type": "text",
"text": "可乐-188"
}]
}, {
"name": "span",
"attrs": {
"class": "reply"
},
"children": [{
"type": "text",
"text": "回复"
}]
}, {
"name": "a",
"attrs": {
"class": "name",
"style": "color: #4e5c7f;font-size: 36rpx;line-height: 48rpx;"
},
"children": [{
"type": "text",
"text": "黄瓜

吕先森

吕先森 (作者)

如图

该问题目前已经被锁定, 无法添加新回复