新增:打包编译功能
This commit is contained in:
15
backend/templates/rest_framework/docs/langs/javascript.html
Normal file
15
backend/templates/rest_framework/docs/langs/javascript.html
Normal file
@@ -0,0 +1,15 @@
|
||||
{% load rest_framework %}
|
||||
<pre class="highlight javascript hide" data-language="javascript"><code>{% code javascript %}var coreapi = window.coreapi // Loaded by `coreapi.js`
|
||||
var schema = window.schema // Loaded by `schema.js`
|
||||
|
||||
// Initialize a client
|
||||
var client = new coreapi.Client()
|
||||
|
||||
// Interact with the API endpoint
|
||||
var action = [{% if section_key %}"{{ section_key }}", {% endif %}"{{ link_key }}"]
|
||||
{% if link.fields %}var params = {
|
||||
{% for field in link.fields %} {{ field.name }}: ...{% if not loop.last %},{% endif %}
|
||||
{% endfor %}}
|
||||
{% endif %}client.action(schema, action{% if link.fields %}, params{% endif %}).then(function(result) {
|
||||
// Return value is in 'result'
|
||||
}){% endcode %}</code></pre>
|
||||
Reference in New Issue
Block a user