fes.js/assets/index.html.fb3234bc.js

79 lines
25 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{_ as p,r as o,o as i,c as r,b as s,d as n,a as e,f as t}from"./app.136d0839.js";const c={},l=t(`<h1 id="api" tabindex="-1"><a class="header-anchor" href="#api" aria-hidden="true">#</a> API</h1><p>Fes.js 统一了API的出口所有运行时API包含Fes.js内置API和插件提供的API全部通过<code>@fesjs/fes</code>导出。</p><div class="language-javascript line-numbers-mode" data-ext="js"><pre class="language-javascript"><code><span class="token keyword">import</span> <span class="token punctuation">{</span> someApi <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&quot;@fesjs/fes&quot;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h2 id="基础api" tabindex="-1"><a class="header-anchor" href="#基础api" aria-hidden="true">#</a> 基础API</h2><h3 id="plugin" tabindex="-1"><a class="header-anchor" href="#plugin" aria-hidden="true">#</a> plugin</h3><div class="custom-container tip"><p class="custom-container-title">提示</p><p>主要在插件里面使用,项目代码中一般用不到。</p></div><p>运行时插件接口,是 Fes.js 内置的跑在浏览器里的一套插件体系。</p><div class="language-javascript line-numbers-mode" data-ext="js"><pre class="language-javascript"><code><span class="token keyword">import</span> <span class="token punctuation">{</span> plugin<span class="token punctuation">,</span> ApplyPluginsType <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&#39;@fesjs/fes&#39;</span><span class="token punctuation">;</span>
<span class="token comment">// 注册插件</span>
plugin<span class="token punctuation">.</span><span class="token function">register</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
<span class="token literal-property property">apply</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token literal-property property">dva</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token literal-property property">foo</span><span class="token operator">:</span> <span class="token number">1</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token literal-property property">path</span><span class="token operator">:</span> <span class="token string">&#39;foo&#39;</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
plugin<span class="token punctuation">.</span><span class="token function">register</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
<span class="token literal-property property">apply</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token literal-property property">dva</span><span class="token operator">:</span> <span class="token punctuation">{</span> <span class="token literal-property property">bar</span><span class="token operator">:</span> <span class="token number">1</span> <span class="token punctuation">}</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token literal-property property">path</span><span class="token operator">:</span> <span class="token string">&#39;bar&#39;</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 执行插件</span>
<span class="token comment">// 得到 { foo: 1, bar: 1 }</span>
plugin<span class="token punctuation">.</span><span class="token function">applyPlugins</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
<span class="token literal-property property">key</span><span class="token operator">:</span> <span class="token string">&#39;dva&#39;</span><span class="token punctuation">,</span>
<span class="token literal-property property">type</span><span class="token operator">:</span> ApplyPluginsType<span class="token punctuation">.</span>modify<span class="token punctuation">,</span>
<span class="token literal-property property">initialValue</span><span class="token operator">:</span> <span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token literal-property property">args</span><span class="token operator">:</span> <span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token literal-property property">async</span><span class="token operator">:</span> <span class="token boolean">false</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="plugin-register-参数包含" tabindex="-1"><a class="header-anchor" href="#plugin-register-参数包含" aria-hidden="true">#</a> <strong>plugin.register</strong> 参数包含:</h4><ul><li>apply 插件文件导出的内容</li><li>path 插件文件路径</li></ul><h4 id="plugin-applyplugins-参数包含" tabindex="-1"><a class="header-anchor" href="#plugin-applyplugins-参数包含" aria-hidden="true">#</a> <strong>plugin.applyPlugins</strong> 参数包含:</h4><ul><li>key坑位的 key</li><li>type执行方式类型详见 <a href="#applypluginstype">ApplyPluginsType</a></li><li>initialValue初始值</li><li>args参数</li><li>async是否异步执行且返回 Promise</li></ul><h3 id="applypluginstype" tabindex="-1"><a class="header-anchor" href="#applypluginstype" aria-hidden="true">#</a> ApplyPluginsType</h3><div class="custom-container tip"><p class="custom-container-title">提示</p><p>主要在插件里面使用,项目代码中一般用不到。</p></div><p>运行时插件执行类型enum 类型,包含三个属性:</p><ul><li>compose用于合并执行多个函数函数可决定前序函数的执行时机</li><li>modify用于修改值</li><li>event用于执行事件前面没有依赖关系</li></ul><h3 id="defineroutemeta" tabindex="-1"><a class="header-anchor" href="#defineroutemeta" aria-hidden="true">#</a> defineRouteMeta</h3><p>定义页面的元信息</p><h3 id="definebuildconfig" tabindex="-1"><a class="header-anchor" href="#definebuildconfig" aria-hidden="true">#</a> defineBuildConfig</h3><p>定义构建配置</p><h3 id="defineruntimeconfig" tabindex="-1"><a class="header-anchor" href="#defineruntimeconfig" aria-hidden="true">#</a> defineRuntimeConfig</h3><p>定义运行时配置</p><h2 id="路由api" tabindex="-1"><a class="header-anchor" href="#路由api" aria-hidden="true">#</a> 路由API</h2>`,23),u={href:"https://next.router.vuejs.org/introduction.html",target:"_blank",rel:"noopener noreferrer"},d=t(`<h3 id="getrouter" tabindex="-1"><a class="header-anchor" href="#getrouter" aria-hidden="true">#</a> getRouter</h3><p>返回当前 <code>router</code> 实例。</p><div class="language-javascript line-numbers-mode" data-ext="js"><pre class="language-javascript"><code><span class="token keyword">import</span> <span class="token punctuation">{</span> getRouter <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&quot;@fesjs/fes&quot;</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> router <span class="token operator">=</span> <span class="token function">getRouter</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
router<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="gethistory" tabindex="-1"><a class="header-anchor" href="#gethistory" aria-hidden="true">#</a> getHistory</h3><p>返回当前路由的History</p><h3 id="useroute" tabindex="-1"><a class="header-anchor" href="#useroute" aria-hidden="true">#</a> useRoute</h3><p>返回当前 <code>route</code> 实例,相当于在模板内使用 <code>$route</code>。必须在 <code>setup</code> 函数内调用。</p><div class="language-javascript line-numbers-mode" data-ext="js"><pre class="language-javascript"><code><span class="token keyword">import</span> <span class="token punctuation">{</span> useRoute <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&quot;@fesjs/fes&quot;</span><span class="token punctuation">;</span>
<span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token punctuation">{</span>
<span class="token function">setup</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">const</span> route <span class="token operator">=</span> <span class="token function">useRoute</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="userouter" tabindex="-1"><a class="header-anchor" href="#userouter" aria-hidden="true">#</a> useRouter</h3><p>返回 <code>router</code> 实例,相当于在模板语法中使用 <code>$router</code>。必须在 <code>setup</code> 函数内调用。</p><div class="language-javascript line-numbers-mode" data-ext="js"><pre class="language-javascript"><code><span class="token keyword">import</span> <span class="token punctuation">{</span> useRouter <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&quot;@fesjs/fes&quot;</span><span class="token punctuation">;</span>
<span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token punctuation">{</span>
<span class="token function">setup</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">const</span> router <span class="token operator">=</span> <span class="token function">useRouter</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="onbeforerouteupdate" tabindex="-1"><a class="header-anchor" href="#onbeforerouteupdate" aria-hidden="true">#</a> onBeforeRouteUpdate</h3><p>添加导航守卫,在当前路由即将更新时触发。类似于之前的<code>beforeRouteUpdate</code>,但是可用于任何组件。卸载组件时,将移除守卫。</p><div class="language-javascript line-numbers-mode" data-ext="js"><pre class="language-javascript"><code><span class="token keyword">import</span> <span class="token punctuation">{</span> onBeforeRouteUpdate <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&quot;@fesjs/fes&quot;</span><span class="token punctuation">;</span>
<span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token punctuation">{</span>
<span class="token function">setup</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token function">onBeforeRouteUpdate</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token parameter">to<span class="token punctuation">,</span> from<span class="token punctuation">,</span> next</span><span class="token punctuation">)</span><span class="token operator">=&gt;</span><span class="token punctuation">{</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="onbeforerouteleave" tabindex="-1"><a class="header-anchor" href="#onbeforerouteleave" aria-hidden="true">#</a> onBeforeRouteLeave</h3><p>添加导航守卫,在当前路由即将离开时触发。类似于之前的<code>beforeRouteLeave</code>,但可用于任何组件。卸载组件时,将移除守卫。</p><div class="language-javascript line-numbers-mode" data-ext="js"><pre class="language-javascript"><code><span class="token keyword">import</span> <span class="token punctuation">{</span> onBeforeRouteLeave <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&quot;@fesjs/fes&quot;</span><span class="token punctuation">;</span>
<span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token punctuation">{</span>
<span class="token function">setup</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token function">onBeforeRouteLeave</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token parameter">to<span class="token punctuation">,</span> from<span class="token punctuation">,</span> next</span><span class="token punctuation">)</span><span class="token operator">=&gt;</span><span class="token punctuation">{</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="createwebhashhistory" tabindex="-1"><a class="header-anchor" href="#createwebhashhistory" aria-hidden="true">#</a> createWebHashHistory</h3><div class="custom-container tip"><p class="custom-container-title">提示</p><p>在开发插件时可能用上,平时一般用不上</p></div><p>创建一个 hash 历史记录。对于没有主机的 web 应用程序 (例如 file://)或当配置服务器不能处理任意URL时这非常有用。注意如果 SEO 对你很重要,你应该使用 <code>createWebHistory</code>。</p><h3 id="createwebhistory" tabindex="-1"><a class="header-anchor" href="#createwebhistory" aria-hidden="true">#</a> createWebHistory</h3><div class="custom-container tip"><p class="custom-container-title">提示</p><p>在开发插件时可能用上,平时一般用不上</p></div><p>创建HTML5历史记录。单页应用程序最常见的历史记录。必须通过 http 服务打开页面地址 。</p><h3 id="creatememoryhistory" tabindex="-1"><a class="header-anchor" href="#creatememoryhistory" aria-hidden="true">#</a> createMemoryHistory</h3><div class="custom-container tip"><p class="custom-container-title">提示</p><p>在开发插件时可能用上,平时一般用不上</p></div><p>创建一个基于内存的历史记录。这个历史记录的主要目的是处理 SSR。它在一个特殊的位置开始这个位置无处不在。如果用户不在浏览器上下文中它们可以通过调用 router.push() 或 router.replace() 将该位置替换为启动位置。</p><h3 id="createrouter" tabindex="-1"><a class="header-anchor" href="#createrouter" aria-hidden="true">#</a> createRouter</h3>`,27),k={href:"https://next.router.vuejs.org/api/#routeroptions",target:"_blank",rel:"noopener noreferrer"},v=t(`<h3 id="routerlink" tabindex="-1"><a class="header-anchor" href="#routerlink" aria-hidden="true">#</a> RouterLink</h3><p>使用自定义组件路由器链接来创建链接,而不是使用常规标签。这使得 Vue 路由器无需重新加载页面即可更改 URL、处理 URL 生成及其编码。</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>router-link</span> <span class="token attr-name">to</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>/about<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>Go to About<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>router-link</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div>`,3),h={href:"https://next.router.vuejs.org/api/#router-link-props",target:"_blank",rel:"noopener noreferrer"},m={href:"https://next.router.vuejs.org/api/#router-link-s-v-slot",target:"_blank",rel:"noopener noreferrer"},b=s("h3",{id:"uselink",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#uselink","aria-hidden":"true"},"#"),n(" useLink")],-1),g={href:"https://next.router.vuejs.org/api/#router-link-s-v-slot",target:"_blank",rel:"noopener noreferrer"},f=t(`<div class="language-javascript line-numbers-mode" data-ext="js"><pre class="language-javascript"><code><span class="token keyword">import</span> <span class="token punctuation">{</span> RouterLink<span class="token punctuation">,</span> useLink <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&#39;@fesjs/fes&#39;</span>
<span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token punctuation">{</span>
<span class="token literal-property property">name</span><span class="token operator">:</span> <span class="token string">&#39;AppLink&#39;</span><span class="token punctuation">,</span>
<span class="token literal-property property">props</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token comment">// add @ts-ignore if using TypeScript</span>
<span class="token operator">...</span>RouterLink<span class="token punctuation">.</span>props<span class="token punctuation">,</span>
<span class="token literal-property property">inactiveClass</span><span class="token operator">:</span> String<span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token function">setup</span><span class="token punctuation">(</span><span class="token parameter">props</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token comment">// \`props\` contains \`to\` and any other prop that can be passed to &lt;router-link&gt;</span>
<span class="token keyword">const</span> <span class="token punctuation">{</span> navigate<span class="token punctuation">,</span> href<span class="token punctuation">,</span> route<span class="token punctuation">,</span> isActive<span class="token punctuation">,</span> isExactActive <span class="token punctuation">}</span> <span class="token operator">=</span> <span class="token function">useLink</span><span class="token punctuation">(</span>props<span class="token punctuation">)</span>
<span class="token comment">// profit!</span>
<span class="token keyword">return</span> <span class="token punctuation">{</span> isExternalLink <span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="routerview" tabindex="-1"><a class="header-anchor" href="#routerview" aria-hidden="true">#</a> RouterView</h3><p>router-view 将显示当前 URL 的对应的路由组件。你可以把它放在任何地方,以适应你的布局。</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>router-view</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>router-view</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>router-view</span> <span class="token attr-name">v-slot</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>{ Component, route }<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>component</span> <span class="token attr-name">:is</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>Component<span class="token punctuation">&quot;</span></span> <span class="token punctuation">/&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>router-view</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div>`,4),y={href:"https://next.router.vuejs.org/api/#router-view-props",target:"_blank",rel:"noopener noreferrer"},x={href:"https://next.router.vuejs.org/api/#router-view-s-v-slot",target:"_blank",rel:"noopener noreferrer"},_=s("h3",{id:"其他-router-methods",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#其他-router-methods","aria-hidden":"true"},"#"),n(" 其他 Router Methods")],-1),w={href:"https://next.router.vuejs.org/api/#router-methods",target:"_blank",rel:"noopener noreferrer"};function j(R,L){const a=o("ExternalLinkIcon");return i(),r("div",null,[l,s("p",null,[n("Fes.js 路由基于 "),s("a",u,[n("Vue Router 4.0"),e(a)]),n(",想了解更多的同学可以看看官方文档。")]),d,s("p",null,[n("创建一个路由器实例,该实例可用于 Vue 应用程序。查看"),s("a",k,[n("路由器选项"),e(a)]),n(",了解可以传递的所有属性的列表。")]),v,s("p",null,[n("可以查看"),s("a",h,[n("官方文档"),e(a)]),n("了解更多 RouterLink 的 Porps。查看"),s("a",m,[n("官方文档"),e(a)]),n("了解 RouterLink 的作用域插槽。")]),b,s("p",null,[n("返回的结果跟 RouterLink 的作用域插槽的属性一致,查看"),s("a",g,[n("官方API"),e(a)]),n("了解更多。")]),f,s("p",null,[n("可以查看"),s("a",y,[n("官方文档"),e(a)]),n("了解更多 RouterView 的 Porps。查看"),s("a",x,[n("官方文档"),e(a)]),n("了解 RouterView 的作用域插槽。")]),_,s("p",null,[n("查看"),s("a",w,[n("vue-router 官方文档"),e(a)]),n("了解更多。")])])}const A=p(c,[["render",j],["__file","index.html.vue"]]);export{A as default};