我曾尝试将moxios Stubrequest与comments/.*/vote之类的正则表达式一起使用,但它不起作用。.*由标识符(整数)填充。你知道怎么做吗?谢谢
代码
moxios.stubRequest('/comments/.*/vote', {
status: 200,
response: {
success: true
}
})发布于 2019-06-11 21:19:44
您需要使用正则表达式,而不是字符串。所以你的代码会变成:
moxios.stubRequest(/\/comments\/.*\/vote/, {
status: 200,
response: {
success: true
}
})发布于 2020-05-23 22:09:04
作为附加解决方案,您可以将var包装在正则表达式中
var str = '/comments/.*/vote';
moxios.stubRequest(new RegExp(str), {
status: 200,
response: {
success: true
}
})https://stackoverflow.com/questions/54691299
复制相似问题