3
CoffeeScript不支持ES6 import
。 (見https://github.com/jashkenas/coffeescript/issues/3162)使用ESScript導入CoffeeScript和Browserify
我試着用下面的語法中的鏈接解釋說:
`import { createAction, handleAction, handleActions } from 'redux-actions'`
但Browserify引發以下錯誤:
Browerify { err:
{ [Error: Parsing file: 'import' and 'export' may only appear at the top level (2:0)]
所以,我目前套牢舊的傳統方式:
reduxActions = require 'redux-actions'
console.log reduxActions.createAction
這工作正常,但迫使我要麼使用reduxActions.createAction
或在每個文件中手動定義createAction = reduxActions.createAction
是否需要它。如果有的話,我正在尋找更好的方法來做到這一點。