小编Jer*_*son的帖子

Javascript然后没有承诺返回val

也许我没有正确使用谷歌搜索。没有参数的 then 函数不会阻塞吗?例如,你有一个承诺:

someFunc = () => {
  return new Promise((res,rej)=>{
   somethingAsync(input).then((val) => res(val))
  })
}
Run Code Online (Sandbox Code Playgroud)

在我们功能的以下实现中。两者都会等待 someFunc 返回值吗?

someFunc().then(dosomethingafter())
someFunc().then((val) => dosomethingafter())
Run Code Online (Sandbox Code Playgroud)

javascript promise ecmascript-6 es6-promise

1
推荐指数
1
解决办法
3467
查看次数

如何在Javascript中获取字符串的href

我正在使用的第 3 方工具构建了一个锚标签,就像这样..

"<a href="http://DevNode/Lists/Publications.aspx#/publication/123">http://DevNode/Lists/Publications.aspx#/publication/123</a>"
Run Code Online (Sandbox Code Playgroud)

我需要隔离 href 以便我可以修剪它。目前我的模式

reg = /^(<a\shref=")? http:\/\/DevNode\/Lists\/Publications.aspx#\/publication\/(\d+)/i {lastIndex: 0} 
Run Code Online (Sandbox Code Playgroud)

如果 href 有这样的前导空格,将无法匹配

"<a href=" http://DevNode/Lists/Publications.aspx#/publication/123"> http://DevNode/Lists/Publications.aspx#/publication/123</a>"
Run Code Online (Sandbox Code Playgroud)

请帮忙

javascript regex

0
推荐指数
1
解决办法
1227
查看次数

标签 统计

javascript ×2

ecmascript-6 ×1

es6-promise ×1

promise ×1

regex ×1