Vue页面数据换行展示

直接上代码,重点是Render里面的处理:

{
    title: "地址",
    dataIndex: "addr",
    key: "addr",
    customRender: (text) => {
        const array = text.split(",");
        const br = <br></br>;
        if (array.length < 2) {
            return text;
        }
        let result = null;
        for (let i=0; i< array.length; i++) {
            if (i ==0 ){
                result = array[i];
            } else {
                result = <span>{result}{ br }{array[i]}</span>
            }
        }
        return <div>{result} </div>
    }
}

注意<br></br>的拼接方式
欢迎扫码关注公众号,更好的交流
欢迎扫码关注公众号,更好的交流

发布了115 篇原创文章 · 获赞 67 · 访问量 10万+

猜你喜欢

转载自blog.csdn.net/meifannao789456/article/details/93752483