[英]Import in isomorphic app
那沒有任何意義:
import {Dispatcher} from 'flux';
console.log('Dispatcher', Dispatcher)
我正在使用與平常相同的樣板文件 ,相同的節點版本,相同的編譯器,相同的方法等。但是上面的console.log
正確地在服務器端記錄了Dispatcher
函數,而在客戶端undefined
。
如果我正在這樣做:
import Flux from 'flux';
console.log('Flux', Flux)
服務器端日志:
Flux { Dispatcher: [Function: Dispatcher] }
客戶端:
actions: undefined
constants: {
TEST_ACTION: "TEST_ACTION"
}
dispatcher: undefined
顯然,我在某個地方犯了一些愚蠢的簡單錯誤,但我找不到它。
依賴關系:
"dependencies": {
"babel-polyfill": "6.5.0",
"fetch-plus": "3.8.1",
"fetch-plus-bearerauth": "3.5.0",
"fetch-plus-json": "3.6.0",
"file-loader": "0.8.5",
"flux": "^2.1.1",
"isomorphic-fetch": "2.2.1",
"keymirror": "^0.1.0",
"koa": "1.2.0",
"koa-proxy": "0.5.0",
"koa-static": "2.0.0",
"object-assign": "^4.0.1",
"react": "0.14.7",
"react-dom": "0.14.7",
"react-inline-css": "2.1.0",
"react-router": "2.0.0",
"react-transmit": "3.1.7"
},
"devDependencies": {
"babel": "6.5.2",
"babel-core": "6.6.5",
"babel-loader": "6.2.4",
"babel-preset-es2015": "6.6.0",
"babel-preset-react": "6.5.0",
"babel-preset-react-hmre": "1.1.1",
"babel-preset-stage-0": "6.5.0",
"concurrently": "2.0.0",
"forever": "0.15.1",
"gulp": "^3.9.1",
"gulp-concat": "^2.6.1",
"gulp-sass": "^3.0.0",
"gulp-uglify": "^2.0.0",
"gulp-uglifycss": "^1.0.6",
"json-loader": "0.5.4",
"just-wait": "1.0.5",
"webpack": "1.13.0",
"webpack-dev-server": "1.14.1",
"webpack-node-externals": "1.0.0"
},
omg ... import看起來像這樣:
import {Dispatcher} from 'flux';
該文件位於文件夾“ flux”中,我已經在該文件夾中創建了index.js
文件,以使其更易於導入Actions.js
和Dispatcher.js
。 出於某種原因,webpack假定在客戶端from 'flux'
表示從此文件夾導入。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.