/** * @description textarea换行符转指定字符 * @param str:要放到textarea的字符串 * @param code:要转换成换行的字符,默认为',' */ export const textareaToString = (str, code = ',') => { let lineFeed = ' ' let reg = new RegExp(lineFeed, 'g') str = str.toString().replace(reg, code) return str } /** * @description 转为textarea换行符 * @param str:要放到textarea的字符串 * @param code:要转换成换行的字符,默认为' ' */ export const stringToTextarea = (str, code = ' ') => { let reg = new RegExp(code, 'g') str = str.replace(reg, ' ') return str }