Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【v3.5.2 发布】注入给页面的模型数据,可以从指定的服务器获取 #50

Closed
huntbao opened this issue Jun 1, 2017 · 0 comments

Comments

@huntbao
Copy link
Collaborator

huntbao commented Jun 1, 2017

在渲染页面的时候,页面中的模型数据可以从指定的服务器获取,在 server.config.js 中配置 modelServer 参数选项即可:

modelServer: {
  host: '',
  queries: {},
  headers: {},
  // path: function (options) {
  //
  // }
}

参数说明如下:

  • host:完整的主机地址,包括协议、主机名、端口
  • queries: 查询参数,键值对的形式
  • headers:自定义请求头,键值对的形式
  • path:
    • path 可以是字符串,也可以是函数;默认不用传,即使用 host + 页面path + queries 的值
    • 如果是函数,则使用函数的返回值,传给函数的参数 options 是一个对象,它包含 host、path(页面的path)、queries、headers 等参数
    • 如果 path 的值为假值,则使用 host + 页面path + queries 的值;
    • 如果 path 的值是相对地址,则会在前面加上 host

注意:后端在向目标服务器发送请求的时候,会带上原始请求的 cookie

注意:host 要写完整的地址,比如:http://192.168.10.25:8080/,最后的斜杠也需要

@huntbao huntbao changed the title 【新功能公告】注入给页面的模型数据,可从自定义的服务器获取 【v3.5.1 新功能】注入给页面的模型数据,可从自定义的服务器获取 Jun 1, 2017
@huntbao huntbao changed the title 【v3.5.1 新功能】注入给页面的模型数据,可从自定义的服务器获取 【v3.5.1 新功能】注入给页面的模型数据,可以从指定的服务器获取 Jun 1, 2017
@huntbao huntbao changed the title 【v3.5.1 新功能】注入给页面的模型数据,可以从指定的服务器获取 【v3.5.2 新功能】注入给页面的模型数据,可以从指定的服务器获取 Jun 1, 2017
@huntbao huntbao changed the title 【v3.5.2 新功能】注入给页面的模型数据,可以从指定的服务器获取 【v3.5.2 发布】注入给页面的模型数据,可以从指定的服务器获取 Jun 1, 2017
@huntbao huntbao closed this as completed Mar 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant