我正在尝试从代表金钱的数值中删除空格。
例如,我想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)