render: (h, params) => {
  return h('div', [
    h('Tooltip', {
    props: { placement: 'top' }
    }, [
    h('span', {
      style: {
        display: 'inline-block',
        width: params.column._width*0.9+'px',
        overflow: 'hidden',
        textOverflow: 'ellipsis',
        whiteSpace: 'nowrap',
      },
      }, params.row),
      h('span', {
        slot: 'content',
        style: { whiteSpace: 'normal', wordBreak: 'break-all' }
      },params.row)
    ])
  ])
}
 
 
2、为了render的复用性所以封装了,item是等钱显示的内容

//资金明细表IView-》Table-》render
export function render(itemColumnCode){
return (h,params)=>{
if(params.row[itemColumnCode]){
let numberAndEnglish = String(params.row[itemColumnCode]).replace(/[^0-9][a-z][A-Z]+/g,''); //正则获取字符串包含数组和大小写英文字母的内容
let ChineseLength = String(params.row[itemColumnCode]).replace(/[^\u4e00-\u9fa5]+/g,'');//正则获取字符串包含汉字的内容
let paramsRowItemColumnCode = numberAndEnglish.length*8 +ChineseLength.length*12;
let paramsRowItemColumnContent = params.row[itemColumnCode];
if(params.row[itemColumnCode].indexOf(" ") !== -1){//如果内容存在空格

//使用正则吧空格替换为span包裹的&nbsp(因为多个空格浏览器只显示一个空格)
paramsRowItemColumnContent=params.row[itemColumnCode].replace(/\s/g,'<span>&nbsp;</span>');
}
if((params.column._width*0.9<paramsRowItemColumnCode)){
return h('div',[
h('Tooltip',{
props:{placement:'bottom'},
transfer:true
},[
h('span',{
style:{//如果内容超出span标签的具体宽度,超出部分显示省略号
display:'inline-block',
width:params.column._width*0.9+'px',
overflow:'hidden',
textOverflow:'ellipsis',
whiteSpace:'nowrap',
},
domProps:{//向iview的dom的Props设置innerHTML用来渲染标签,iview的新版本只能渲染字符串
innerHTML:paramsRowItemColumnContent
}
}),
h('span',{
slot:'content',
style:{whiteSpace:'normal',wordBreak:'break-all'},
domProps:{
innerHTML:paramsRowItemColumnContent
}
},)
])
])
}else{
return h('div',[
h('span',{
domProps:{
innerHTML:paramsRowItemColumnContent
}
})
])
}
}
}
}

IVIEW对的table组件超出长度用省略号代替,使用气泡提示。的更多相关文章

  1. iview中关于table组件内放入Input会失去焦点

    table里面的数据是一个数组,父组件传入的.子组件是截图的内容.当每个input框数据发生变化时,把数据传给父组件.在父组件做表单的提交. github内已经提到过这个问题(https://gith ...

  2. 把iview中的table组件写成了一个公用组件,在另一个组件里去引用它的时候rander函数里的this指向不正确

    在vue项目里使用iview制作后台管理系统时,由于有多个页面都需要用到table组件,所以就把table写到了一个公共组件里,在其他页面去引用它,但是这时会发现一个问题,就是render函数里的th ...

  3. iview中,table组件在缩进时产生的bug。

    问题描述: 在父元素因为缩进的关系撑开时,table组件不会因为父元素的撑开而自适应,问题如图 解决办法:在父一级的组件中使用table {width: 100% !important},强制使表格宽 ...

  4. table表格超出部分显示省略号

    做table表格时,某一列字数比较多,希望超出宽度的部分以省略号显示 设置table的布局 默认automatic 以表格内容显示相应宽度 改成fixed 以表格列宽显示内容 table{    ta ...

  5. iview库表table组件内嵌套Select组件

    表格内render函数渲染Select组件   { title: '属性值', key: 'values', render:(h,params)=>{ return h('Select',{   ...

  6. table中td文字超出长度用省略号隐藏超出内容,鼠标点击内容全部显示

    1,设置css样式 <style>table {width: 100%;float: left;table-layout:fixed;width:600px;border:1px soli ...

  7. html 固定长度 超出长度 显示省略号

    a{         width: 80px;/* 要显示文字的宽度 */         float: left;/* 左对齐,不设置的话只在IE下好用 */         overflow: h ...

  8. DIV内容超出长度显示省略号,鼠标移上自动显示全部内容(EasyUI DataGrid)

    如果想把DIV中超出的文本显示成省略号,而不是换行全部显示,有2个办法. 注:本文主要是以EasyUI的DataGrid为案例的,如果是其他场景只要底层是用DIV显示文本的应该都能使用. 首先可以给此 ...

  9. JS input输入框字数超出长度显示省略号.....

    样式添加: overflow:hidden; white-space:nowrap; text-overflow:ellipsis;

随机推荐

  1. D - Windows Message Queue

    来源hdu1509 Message queue is the basic fundamental of windows system. For each process, the system mai ...

  2. linux的基本操作(mysql 的基本操作)

    Mysql 的基本操作 在前面两个章节中已经介绍过MySQL的安装了,但是光会安装还不够,还需要会一些基本的相关操作.当然了,关于MySQL的内容也是非常多的,只不过对于linux系统管理员来讲,一些 ...

  3. HTML load事件和DOMCOntentLoaded事件

    JS高程 p14 “异步脚本一定会在页面的load事件前执行,但可能会在DOMContentLoaded事件触发之前或之后执行”   普通script标签会阻塞DOM的解析 DOMcontentLoa ...

  4. python中print(obj) 与sys.stdout.write()的区别

    print(obj) 其实等价于sys.stdout.write(obj+\n),而\r表示回到行首,所以需要输出进度条时可以用以下代码 rate = float(has_sent) / float( ...

  5. Yarn Node Labels

    Yarn Node Labels + Capacity-Scheduler 在yarn-site.xml中开启capacity-schedule yarn-site.xml <property& ...

  6. SSM框架——详细整合教程(Spring+SpringMVC+MyBatis)【申明:来源于网络】

    SSM框架--详细整合教程(Spring+SpringMVC+MyBatis)[申明:来源于网络] 地址:http://blog.csdn.net/u014662268/article/details ...

  7. Codeforces 584 - A/B/C/D/E - (Done)

    链接:https://codeforces.com/contest/584 A - Olesya and Rodion - [水] 题解:注意到 $t$ 的范围是 $[2,10]$,对于位数小于 $2 ...

  8. oracle日期格式化

    TO_CHAR(t.CAMERA_CREAT_TIME, 'YYYY-MM-DD HH24:MI:SS') as point_registerdate,TO_CHAR(t.CAMERA_MODIFY_ ...

  9. springboot2.0集成shiro出现ShiroDialect报错找不到AbstractTextChildModifierAttrPr

    @Bean public ShiroDialect shiroDialect() { return new ShiroDialect(); } 报错出现找不到org/thymeleaf/process ...

  10. jsr-303 参数校验—自定义校验注解

    1.为什么要自定义? 通过上篇学习,了解到很多常用注解了,但是呢,总是有那么些需求....   2.案例分析(手机号格式) 2.1.需要验证的实体 Bean public class LoginVo ...