replace(/\s+/g, ‘’)即可 小程序示例:
textInput(e) { this.setData({ textContent: e.detail.value.replace(/\s+/g, '') }) },