我有一个用Knockout编写的前端SPA.由于它的大小,我想将它分成多个文件,使我的文件夹结构看起来像这样:
node_modules
|- knockout
\- requirejs
components
|- MyFutureViewModel.js
\- etc.
index.html
app.js
Run Code Online (Sandbox Code Playgroud)
Index.html看起来像这样:
<!DOCTYPE html>
<html>
<head>
<title>NCounter</title>
<meta charset="utf-8">
<script type="text/javascript" data-main="app.js" src="./node_modules/requirejs/require.js"></script>
</head>
<body>
<p>The name is <input data-bind="value: name" /></p>
<p>You entered <span data-bind="text: name"></span>.</p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我的app.js文件看起来像这样:
requirejs.config({
//Pass the top-level main.js/index.js require
//function to requirejs so that node modules
//are loaded relative to the top-level JS file.
nodeRequire: require
});
require(['knockout'], function(ko) {
var viewModel = function() {
name: ko.observable('name')
};
ko.applyBindings(viewModel);
});
Run Code Online (Sandbox Code Playgroud)
但是,requirejs似乎没有看到淘汰赛.我缺少配置或步骤吗?
我有几个 Docker 容器在桥接网络上充当 Web 服务器。我想使用 Nginx 作为代理,在桥接网络外部公开服务(Web),并使用服务器端包含嵌入来自其他服务(即 wiki)的内容。
长话短说,我正在尝试使用下面的配置,但我的位置无法正常工作。/位置工作正常,但是当我添加另一个位置(例如/wiki)或将/更改为更具体的位置(例如/web)时,我从 Nginx 收到一条消息,说它“无法获取 /wiki”或“可以”分别获取/web”:
events {
worker_connections 1024;
}
http {
upstream wiki {
server wiki:3000;
}
upstream web {
server web:3000;
}
server {
ssi on;
location = /wiki {
proxy_pass http://wiki;
}
location = / {
proxy_pass http://web;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我已附加到 Nginx 容器并验证我可以使用 CURL 访问其他容器 - 它们似乎工作正常。
我还阅读了 Nginx 陷阱,并知道使用主机名(wiki、Web)并不理想,但我提前不知道 IP 地址,并尝试通过告诉 docker-compose 来解决任何 DNS 问题nginx 容器依赖于 web 和 wiki。
有任何想法吗?