首页 > 技术文章 > render函数里面实现for循环的写法

JeneryYang 2019-01-02 16:21 原文

核心代码
render: (h, params) => { let texts = ''; //表格列显示文字 let index = params.row.IpAddress.indexOf(',') if (params.row.IpAddress !== null) { if (index > -1) { texts = params.row.IpAddress.substring(0, index) + "..."; } else { texts = params.row.IpAddress; } } let IPArr = params.row.IpAddress.split(',') // console.log('组合的数组是:', IPArr) return h('Tooltip', { props: { // content: params.row.IpAddress, placement: "left-start" }, style: { cursor: 'pointer' } },[ texts, IPArr.map(function (item,index) { return h('div',{ slot: 'content', style: { whiteSpace: 'normal', wordWrap: 'break-word' } }, [ h('p' , item) ]) }) ]) // return h('Tooltip', { // props: { // // content: params.row.IpAddress, // placement: "left-start" // }, // style: { // cursor: 'pointer' // } // }, [ // // h('span', params.row.IpAddress) // texts, // h('div', { // slot: 'content', // style: { // whiteSpace: 'normal', // wordWrap: 'break-word' // } // }, [ // h('p' , IPArr[0]), // h('p' , IPArr[1]), // h('p' , IPArr[2]), // h('p' , IPArr[3]) // ]) // ]) }

 

推荐阅读