问题描述
这是上下文:
我正在编写一个 Python 代码,它使用 link 中的说明将 HTML 页面转换为 PDF 文件。我现在处理 POST 请求,该请求将作为输入的 HTML 文件,并在后者 link 中有一些精确的参数。
link 声明 HTML 输入文件必须由一些参数定义,在此示例中分组:
在这个例子中,我不明白这部分是什么意思: "json": "[\"a\": \"b\"]"
?以及我如何适应我的情况。
问题来了:
有关该领域 (cpf:inputs > params > cpf:inline > json
) 的文献陈述如下:
json(string,optional)
JavaScript variables to be placed in global scope to reference while rendering the HTML.
This mechanism is intended to be used to supply data that might otherwise be retrieved using ajax requests.
The actual mechanics of accessing this content varies depending if rendering from a zip file or from a url.
When rendering from a zip file,the source collateral must include a script element such as:
<script src='./json.js' type='text/javascript'></script>
When rendering from a URL,the content of this json object is injected into the browser VM before the page is rendered.
default: {}
如果有人能够阅读并向我解释上面引用的这段文字的含义,将会有所帮助。谢谢!
解决方法
如果不想每次使用脚本都做一次ajax请求,可以访问ajax页面,用Ctrl+A复制全部内容,然后粘贴到一个空的javascript文件中,可以另存为例如 module.js。当您到达通常执行请求的程度时,您可以将其替换为 .祝你好运!
PS:你的问题表述得很好,我会赞成它,但我现在没有足够的声誉......