1、输入框
<input v-model="inputValue" ></input>
<span v-show="false">{{resultString}}</span>
2、数据参数
data(){
return {
inputValue:''
}
}
3、变更数据
computed: {
resultString () {
const reg = /[\n\r\t\s]+/g // 注意:我添加了+来确保至少替换一个连续的空白字符
console.log('resultString', this.inputValue)
console.log('resultString', this.inputValue.replace(reg, ','))
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
this.inputValue = this.inputValue.replace(reg, ',')
return this.inputValue.replace(reg, ',')
}
},
4、应用场景
拷贝Excel或者其他需要多个同一属性的内容。