瞎扯淡 在 Webpacker 的 Vuejs 项目中用 Coffeescript

nong · May 26, 2017 · Last by apexy replied at May 27, 2017 · 3337 hits

正在头疼括号问题的时候偶然想看看 Coffeescript 2 的进度,惊喜的发现已经支持 modules 了http://coffeescript.org/v2/#modules

加上

"coffeescript": "^2.0.0-alpha1",
"coffeescript-loader": "^0.0.10",

然后.vue 里面

<script lang=coffeescript>

就可以用了

page_ids = state.pages
  .filter (p) -> p.checked
  .map (p) -> p.id

彻底治好了我的括号恐惧症 🙂

而且其实比起 Ruby 我更喜欢 Coffee 因为没有 end

因为种种原因 (运行没问题,precompile 会出错,UglifyJS?)Destructuring AssignmentString Interpolation用不了, 前面那个自己赋值,后面那个用加号

actions:
  loadIdea: (context, idea_id) ->
    state = context.state
    dispatch = context.dispatch
    commit = context.commit

    url = state.host + "/ideas/" + idea_id + ".json?token=" + state.token

alpha 不敢用在生产环境。。。

都用上构建工具了,不理解为什么还要用 Coffeescript 而不是 ES6+。

Coffee V2 已经 beta2 啦,各种 ES6 的新特性,随便用,爽歪歪

@hz_qiuyuanxin 当然有必要啊,ES6 好用,Coffee 更好用,为啥有了 ES6 就不能用 Coffee 了,两者又不矛盾 😏

看了下 coffeescript 2.0,和 es6 没什么差别了,如 import modules 的支持。而 coffeescript 的简洁写法更对我的胃口——看到 JS 那一堆堆该死的大括号就想吐。

You need to Sign in before reply, if you don't have an account, please Sign up first.