当我浏览客户端通道代码(在 phoenix.js 文件中)时,我看到它使用 ES6。示例代码:
let chan = socket.chan("rooms:123", {token: roomToken})
// chan.on("new_msg", msg => console.log("Got message", msg) )
// $input.onEnter( e => {
// chan.push("new_msg", {body: e.target.val})
// .receive("ok", (message) => console.log("created message", message) )
// .receive("error", (reasons) => console.log("create failed", reasons) )
// .after(10000, () => console.log("Networking issue. Still waiting...") )
this.onError( reason => {
this.socket.log("channel", `error ${this.topic}`, reason)
this.state = CHAN_STATES.errored
this.rejoinTimer.setTimeout()
})
这意味着它不会在 IE 和 Safari 中本地运行(至少)。我不应该使用某种 polyfills 吗?什么是最好的方法/polyfill?另外,我的印象是 polyfills 涵盖类/let/...但不包括箭头函数/新字符串插值。我应该自己改变那些吗?