小编qat*_*123的帖子

如何从 Cypress 中的字符串中删除空格

我正在尝试从代表金钱的数值中删除空格。

例如,我想1 000 kr成为1000。当货币为10 000

我正在使用此函数来删除,kr但是当我尝试添加另一个函数时.replace它不起作用:

Cypress.Commands.add('currency', (selector) => {
      cy.get(selector)
        .children()
        .eq(1)
        .invoke('text') // get text
        .then((text) => +text.replace('kr', '').trim());
    });
Run Code Online (Sandbox Code Playgroud)

如何添加另一个 .replace 来删除数值中的额外空格? 在此输入图像描述

html javascript ascii removing-whitespace cypress

7
推荐指数
1
解决办法
2万
查看次数

标签 统计

ascii ×1

cypress ×1

html ×1

javascript ×1

removing-whitespace ×1