2017-09-14 57 views
2

我是Fable的新品,我從一個不同的文件打開一個自定義模塊時遇到了一些問題。如何從寓言-F中的其他文件打開模塊#

這是我的基本文件設置

node_modules 
| 
public 
| 
src 
|_ App.fsx 
|_ OtherFile.fsx 

裏面的App.fsx文件:

open CustomModule 

裏面的OtherFile.fsx文件

module CustomModule = 

    let greeting = 
     printfn "hello from CustomModule" 

這裏是我的fableconfig.json文件:

{ 
    "projFile": "./src/App.fsx", 
    "outDir": "./public", 
    "scripts": { 
     "postbuild": "./node_modules/.bin/webpack" 
    } 

}

每當我嘗試引用CustomModule時,出現The namespace or module 'CustomModule' is not defined.錯誤。有任何想法嗎?

+1

寓言最近發生了很大變化。我不確定'fableconfig.json'是否仍然是一件事情。我沒有看到它[這裏](http://fable.io/docs/getting-started.html)。你在什麼版本上?你是否遵循特定指南?它可能已過時。 – TheQuickBrownFox

+0

你有沒有試過'打開OtherFile.CustomModule'?通常,當您在整個文件中定義一個頂級模塊時,不要在其後面放置'=',而且不需要縮進下面的內容。這可以解決您的問題,而無需更改「open」語句。 – TheQuickBrownFox

+0

@TheQuickBrownFox我一直在使用這個[guide](http://inchingforward.com/2017/03/getting-started-with-fable-elmish/),它是在6個月前創建的。有更好的資源我應該使用?我嘗試刪除「=」符號和額外的縮進,但沒有骰子。 –

回答

0

原來有一個類似的問題here,他的答案解決了我的問題。

只需撥打以下加載其他模塊

#load "OtherFile.fsx" 
相關問題