vue拼接换行符

//处理换行
var str = 'abc123'
var index = parseInt(str / 2) //从中间开始换行
var charArray = str.split('');//将abc123拆分成数组 ["a","b","c","1","2","3"]
charArray[index] = '\n' + charArray[index]
var newStr = charArray.join('')

//最终页面显示就是
abc
123

方法2:

//处理换行
var str = 'abc123'
var index = parseInt(str / 2) //从中间开始换行
var charArray = str.split('');//将abc123拆分成数组 ["a","b","c","1","2","3"]
charArray[index] = '<br/>' + charArray[index]
var newStr = charArray.join('')

//最终页面显示就是
abc
123
Logo

前往低代码交流专区

更多推荐