amis/gh-pages/docs/sdk.js

34 lines
25 KiB
JavaScript
Raw Normal View History

2019-05-09 19:30:08 +08:00
define('docs/sdk.md', function(require, exports, module) {
2019-05-10 14:12:15 +08:00
module.exports = {
"title": "如何使用",
2019-05-15 15:14:53 +08:00
"html": "<h2><a class=\"anchor\" name=\"%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8\" href=\"#%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8\" aria-hidden=\"true\"><svg aria-hidden=\"true\" class=\"octicon octicon-link\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>如何使用</h2><pre><code class=\"lang-bash\">npm <span class=\"hljs-selector-tag\">i</span> amis\n</code></pre>\n<p>安装完后可以在 React Component 这么使用。</p>\n<pre><code class=\"lang-tsx\"><span class=\"hljs-keyword\">import</span> * as <span class=\"hljs-type\">React</span> from <span class=\"hljs-symbol\">'reac</span>t';\n<span class=\"hljs-keyword\">import</span> {\n render as renderAmis\n} from <span class=\"hljs-symbol\">'ami</span>s';\n\n<span class=\"hljs-class\"><span class=\"hljs-keyword\">class</span> <span class=\"hljs-title\">MyComponent</span> <span class=\"hljs-keyword\">extends</span> <span class=\"hljs-title\">React</span>.<span class=\"hljs-title\">Component&lt;any</span>, <span class=\"hljs-title\">any&gt;</span> </span>{\n render() {\n <span class=\"hljs-keyword\">return</span> (\n &lt;div&gt;\n &lt;p&gt;通过 amis 渲染页面&lt;/p&gt;\n {renderAmis({\n <span class=\"hljs-comment\">// schema</span>\n <span class=\"hljs-comment\">// 这里是 amis 的 Json 配置。</span>\n <span class=\"hljs-class\"><span class=\"hljs-keyword\">type</span></span>: <span class=\"hljs-symbol\">'pag</span>e',\n title: '简单页面',\n body: '内容'\n }, {\n <span class=\"hljs-comment\">// props</span>\n }, {\n <span class=\"hljs-comment\">// env</span>\n <span class=\"hljs-comment\">// 这些是 amis 需要的一些接口实现</span>\n <span class=\"hljs-comment\">// 可以参考本项目里面的 Demo 部分代码。</span>\n\n updateLocation: (location:string<span class=\"hljs-comment\">/*目标地址*/</span>, replace:boolean<span class=\"hljs-comment\">/*是replace还是push*/</span>) =&gt; {\n <span class=\"hljs-comment\">// 用来更新地址栏</span>\n },\n\n jumpTo: (location:string<span class=\"hljs-comment\">/*目标地址*/</span>) =&gt; {\n <span class=\"hljs-comment\">// 页面跳转, actionType: link、url 都会进来。</span>\n },\n\n fetcher: ({\n url,\n method,\n data,\n config\n }:{\n url:string<span class=\"hljs-comment\">/*目标地址*/</span>,\n method:<span class=\"hljs-symbol\">'ge</span>t' | <span class=\"hljs-symbol\">'pos</span>t' | <span class=\"hljs-symbol\">'pu</span>t' | <span class=\"hljs-symbol\">'delet</span>e'<span class=\"hljs-comment\">/*发送方式*/</span>,\n data: <span class=\"hljs-class\"><span class=\"hljs-keyword\">object</span> <span class=\"hljs-title\">|</span> <span class=\"hljs-title\">void/*数据*/</span>,</span>\n config: <span class=\"hljs-class\"><span class=\"hljs-keyword\">object</span><span class=\"hljs-title\">/*其他配置*/</span></span>\n }) =&gt; {\n <span class=\"hljs-comment\">// 用来发送 Ajax 请求,建议使用 axios</span>\n },\n notify: (<span class=\"hljs-class\"><span class=\"hljs-keyword\">type</span></span>:<span cl
2019-05-10 14:12:15 +08:00
"toc": {
"label": "目录",
"type": "toc",
"children": [
{
"label": "如何使用",
"fragment": "%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8",
"fullPath": "#%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8",
"level": 2
2019-05-09 19:30:08 +08:00
},
2019-05-10 14:12:15 +08:00
{
"label": "工作原理",
"fragment": "%E5%B7%A5%E4%BD%9C%E5%8E%9F%E7%90%86",
"fullPath": "#%E5%B7%A5%E4%BD%9C%E5%8E%9F%E7%90%86",
"level": 2
},
{
"label": "自定义组件",
"fragment": "%E8%87%AA%E5%AE%9A%E4%B9%89%E7%BB%84%E4%BB%B6",
"fullPath": "#%E8%87%AA%E5%AE%9A%E4%B9%89%E7%BB%84%E4%BB%B6",
"level": 2
}
],
"level": 0
}
};
2019-05-09 19:30:08 +08:00
});