这是我的咖啡,我根本不明白为什么这是错误的。我不断收到意外错误。
renderTable:()=>
@table = d3.select("#search-results-area").append("table").attr("id",@tableId).attr("class","visualization-panel")
@thead = @table.append("thead")
@tbody = @table.append("tbody")
@input = @table.append("input").attr("id",@inputId).on("keydown",(d)=>
console.log("keydown")
console.log
toFilter = $(@input[0][0]).val()
window.setTimeout(()=>
toFilter = $(@input[0][0]).val()
@tbody.selectAll("tr")
,500)
)
当我取出@tbody.selectAll("tr")
时,它起作用了,这让我感到困惑。
我该如何解决这个问题?
最佳答案
我相信这与您定义 window.setTimeout
部分的方式有关。由于缩进和括号,最后的 ,500)
部分导致编译错误。尝试将该部分更改为:
window.setTimeout ( ->
toFilter = $(@input[0][0]).val()
@tbody.selectAll("tr")
), 500
将右括号缩进到与窗口
相同的位置。这应该可以修复编译问题。
关于javascript - CoffeeScript 编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17432223/