関数をファイルにインポートし、そのファイルから関数をエクスポートしようとしています。これは簡単なはずですが、何らかの理由でそれを動作させることができません。module.exportsとES6を使用してインポートをエクスポートする
search_action.js
function search_actions() {
this.receive_results = function() {
return {
type: 'RECEIVE_RESULTS',
results: results
}
}
}
module.exports = search_actions
index.js
require('es6-promise').polyfill();
var SearchActions = require('./search_actions.js')
var search_actions = new SearchActions()
//console.log(search_actions.receive_results)
export search_actions.receive_results
index.jsの底に輸出が事実にもかかわらず、予期しないトークンで失敗することはconsole.log(search_actions.receive_results)プリント関数。では、これを行う正しい方法は何ですか?
*「予期しないトークンは」* * *あなたは、構文エラーを有することを意味します。 'search_actions.receive_results'が正しい値を持っているかどうかは、何もしません。 –