![](/img/trans.png)
[英]casper js how can i pass varibales from one homade function to another
[英]global varibales from another js
我的 webpack.config.js 文件如下
var path = require('path');
var webpack = require('webpack');
module.exports = {
entry: [
'./js/config.js',
'./js/app.js'
],
output: {
path: __dirname,
filename: './js/app.bundle.js',
libraryTarget: 'var',
library: 'ui'
}
};
我的 config.js 文件具有全局變量 baseURL,其中 app.js 正在使用 config.js 文件
var hostname_ = window.location.hostname;
var port_ = window.location.port;
var baseURL = "http://" + hostname_ + ":"+ port_ + "/admin/";
module.exports = {
baseURL: baseURL
};
在瀏覽器中我收到錯誤
ReferenceError: baseURL is not defined
在 app.js 中導入 baseURL:
import baseURL from './config'
或者:
var baseURL = require('./config')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.