加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angular – 如何从typescript中的字符串中删除空格?

发布时间:2020-12-17 06:57:52 所属栏目:安全 来源:网络整理
导读:参见英文答案 How to remove whitespace in text????????????????????????????????????2个 在我的angular 5项目中,使用typescript我在这样的字符串上使用.trim()函数,但它不是删除空格而且也没有给出任何错误. this.maintabinfo = this.inner_view_data.trim
参见英文答案 > How to remove whitespace in text????????????????????????????????????2个
在我的angular 5项目中,使用typescript我在这样的字符串上使用.trim()函数,但它不是删除空格而且也没有给出任何错误.

this.maintabinfo = this.inner_view_data.trim().toLowerCase();
// inner_view_data has this value = "Stone setting"

https://www.typescriptlang.org/docs/handbook/release-notes/typescript-1-4.html本文明确指出.trim()是打字稿的一部分.

从typescript中的字符串中删除空格的最佳方法是什么?

解决方法

The trim() method removes whitespace from both sides of a string.

你可以使用javascript替换方法来删除像

"hello world".replace(/s/g,"");

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读