vue拼接换行符

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] = '
'
+ charArray[index] var newStr = charArray.join('') //最终页面显示就是 abc 123

你可能感兴趣的:(Vue教程及问题解决,vue.js,sql)