我有一个私有 VPS,想要使用 nginx 托管基于子域的多个节点应用程序(或静态网站)。
我想实现这样的目标:
johndoe.com -> node app 1 (port 5000)
blog.johndoe.com -> node app 2 (port 5001)
statichtml.johndoe.com -> static html from defined path
Run Code Online (Sandbox Code Playgroud)
现在我在站点可用/默认文件中有这种配置。
server {
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name www.johndoe.com johndoe.com; # managed by Certbot
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade; …Run Code Online (Sandbox Code Playgroud) 我正在尝试通过单击按钮将 json 响应中的元素添加到我现有的数组中,但是我在正确添加这些元素时遇到了问题。
在这里,我有一个名为 results 的空数组,我在其中存储响应中的数据。
export default {
name: 'Posts',
props: ['user_id'],
data: function(){
return{
results: [],
pageNumber: 1,
}
},.....
Run Code Online (Sandbox Code Playgroud)
这是我获取数据的方法:
getData: function () {
var vm = this;
axios.get('http://127.0.0.1:8000/api/posts?page=' + vm.pageNumber)
.then(function (response) {
vm.results += response.data.data;
})
.catch(function (error) {
});
},
Run Code Online (Sandbox Code Playgroud)
在这种方法中,我将响应数据添加到数组中,如下所示:
vm.results += response.data.data;
我的响应是正确的,但在此操作后,我的结果数组如下所示:“[object Object],[object Object]...”
我还尝试通过 push 方法添加新元素:
vm.results.push(response.data.data);
但是,元素被添加到新数组中,但我想将对象添加到现有数组中。
这是我的回复的结构:
{"current_page":1,
"data":[
{
"id":60,
"title":"Post 1",
"body":"Post 1 body",
"created_at":"2018-06-09 18:33:40",
"updated_at":"2018-06-09 18:33:40",
"user_id":8
},
{
"id":61,
"title":"Post 2",
"body":"post 2 …Run Code Online (Sandbox Code Playgroud)