优化Solr Web UI索引名过长的显示效果

## Solr索引名过长,建议显示缩略和title全名

1. 直接在Web页面调整DOM标签text的样式,使得自动缩略 -> 页面上直接调整是可见的

2. js中通过append('text')不会自动缩略 -> 添加foreignObject包装一层,但是元素突然不显示了

3. 发现用到了d3.js类库,d3还要求html标记以xhtml作为前缀 -> 正常显示缩略和title全名

```

node.append('foreignObject')

    .attr('width', '180')

    .attr('height', '19')

    .append('xhtml:text')

    .attr('dx', function (d) {

        return 0 === d.depth ? -8 : 8;

    })

    .attr('dy', function (d) {

        return 5;

    })

    .attr('text-anchor', function (d) {

        return 0 === d.depth ? 'end' : 'start';

    })

    .attr('title', helper_node_text)

    .attr('style', 'overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; width: 180px; padding-left: 5px;')

    .text(helper_node_text);

```

## Reference

https://www.jianshu.com/p/263fce04422c

https://blog.csdn.net/Mosicol/article/details/80105686

https://cloud.tencent.com/developer/ask/133148

https://ask.helplib.com/html/post_7009784

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容