├── CHANGELOG.md ├── lib ├── app │ ├── .temp │ │ ├── override.styl │ │ ├── style.styl │ │ ├── enhanceApp.js │ │ └── themeEnhanceApp.js │ ├── store.js │ ├── root-mixins │ │ ├── index.js │ │ ├── activeHeaderLinks.js │ │ └── updateMeta.js │ ├── index.dev.html │ ├── components │ │ ├── ClientOnly.js │ │ ├── Content.js │ │ ├── OutboundLink.vue │ │ └── Badge.vue │ ├── serverEntry.js │ ├── util.js │ ├── index.ssr.html │ ├── SWUpdateEvent.js │ └── clientEntry.js ├── noop.js ├── webpack │ ├── noopModule.js │ ├── HeadPlugin.js │ ├── DevLogPlugin.js │ ├── createServerConfig.js │ └── createClientConfig.js ├── default-theme │ ├── styles │ │ ├── toc.styl │ │ ├── wrapper.styl │ │ ├── config.styl │ │ ├── arrow.styl │ │ ├── custom-blocks.styl │ │ ├── mobile.styl │ │ └── nprogress.styl │ ├── search.svg │ ├── NotFound.vue │ ├── DropdownTransition.vue │ ├── SidebarButton.vue │ ├── NavLink.vue │ ├── SidebarGroup.vue │ └── SWUpdatePopup.vue ├── index.js ├── util │ ├── shared.js │ ├── logger.js │ ├── parseHeaders.js │ └── index.js ├── service-worker │ └── skip-waiting.js ├── markdown │ ├── hoist.js │ ├── preWrapper.js │ ├── slugify.js │ ├── lineNumbers.js │ ├── containers.js │ ├── highlight.js │ ├── snippet.js │ ├── highlightLines.js │ └── index.js ├── eject.js └── prepare │ ├── loadConfig.js │ ├── index.js │ ├── codegen.js │ └── util.js ├── docs ├── assets │ ├── css │ │ ├── 7.styles.c8b06cc2.css │ │ ├── 4.styles.4c7ddd69.css │ │ ├── 6.styles.7081061c.css │ │ ├── 3.styles.e7495a9d.css │ │ ├── 5.styles.d250c3e3.css │ │ ├── 2.styles.58c85033.css │ │ └── 1.styles.445f32b6.css │ ├── js │ │ ├── 7.c8b06cc2.js │ │ ├── 1.445f32b6.js │ │ ├── 2.58c85033.js │ │ ├── 53.49d814c3.js │ │ ├── 8.928a4419.js │ │ ├── 48.9e2f6119.js │ │ ├── 64.4b0c2825.js │ │ ├── 50.6ea8d75d.js │ │ ├── 35.0d7b47e4.js │ │ ├── 49.ebed9df6.js │ │ ├── 57.f1316fb6.js │ │ ├── 69.9e52d998.js │ │ ├── 18.faddd431.js │ │ ├── 72.38ef9238.js │ │ ├── 45.d5a892d0.js │ │ ├── 75.fd9bf91f.js │ │ ├── 70.6909a909.js │ │ ├── 23.7c6d25d9.js │ │ ├── 46.b2597f58.js │ │ ├── 43.8b6224f6.js │ │ ├── 39.84216f96.js │ │ ├── 56.627b1a35.js │ │ ├── 36.529eaf6d.js │ │ └── 42.219bb0ac.js │ └── img │ │ └── search.683d46b0.svg ├── logo.jpg ├── logo.png ├── avatar.jpg ├── avatar.png ├── baidu.png ├── project.jpg ├── img │ └── improve.png ├── algorithm │ ├── 4.14.png │ ├── 4.16.png │ ├── 4.18.png │ ├── 4.7.png │ ├── 4.8.png │ ├── 5.10.png │ ├── 5.16.png │ ├── 5.17.png │ ├── 5.18.png │ ├── 5.7.png │ ├── 6.1.png │ └── 6.13.png ├── FastStoneEditor.jpg ├── icons │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ ├── apple-touch-icon.png │ ├── mstile-150x150.png │ ├── android-chrome-192x192.png │ ├── android-chrome-512x512.png │ ├── apple-touch-icon-60x60.png │ ├── apple-touch-icon-76x76.png │ ├── apple-touch-icon-120x120.png │ ├── apple-touch-icon-152x152.png │ ├── apple-touch-icon-180x180.png │ └── msapplication-icon-144x144.png ├── line-numbers-mobile.gif ├── line-numbers-desktop.png └── manifest.json ├── test ├── docs-simple │ └── README.md ├── prepare │ ├── fixtures │ │ ├── docs-simple │ │ │ └── README.md │ │ ├── docs-custom-theme │ │ │ ├── .vuepress │ │ │ │ ├── theme │ │ │ │ │ └── Layout.vue │ │ │ │ └── config.js │ │ │ └── README.md │ │ └── docs-simple-config │ │ │ ├── README.md │ │ │ └── .vuepress │ │ │ └── config.js │ └── util.spec.js ├── markdown │ ├── fragments │ │ ├── code.md │ │ ├── container-tip.md │ │ ├── container-v-pre.md │ │ ├── code-snippet.md │ │ ├── container-danger.md │ │ ├── container-tip-override.md │ │ ├── container-warning.md │ │ ├── snippet.js │ │ ├── code-highlightLines-single.md │ │ ├── code-snippet-highlightLines-multiple.md │ │ ├── code-snippet-highlightLines-single.md │ │ ├── code-highlightLines-multiple.md │ │ └── hoist.md │ ├── __snapshots__ │ │ ├── highlight.spec.js.snap │ │ ├── highlightLines.spec.js.snap │ │ ├── hoist.spec.js.snap │ │ ├── link.spec.js.snap │ │ ├── lineNumers.spec.js.snap │ │ ├── snippet.spec.js.snap │ │ └── containers.spec.js.snap │ ├── highlight.spec.js │ ├── containers.spec.js │ ├── util.js │ ├── hoist.spec.js │ ├── slugify.spec.js │ ├── highlightLines.spec.js │ ├── lineNumers.spec.js │ ├── snippet.spec.js │ └── link.spec.js ├── hoc.js ├── jest.config.js ├── prepare.js ├── default-theme │ ├── __snapshots__ │ │ ├── NavLink.spec.js.snap │ │ └── DropdownLink.spec.js.snap │ ├── DropdownLink.spec.js │ └── NavLink.spec.js ├── app │ └── Content.spec.js └── util.js ├── src ├── zh │ ├── react │ │ ├── React组件.md │ │ ├── JSX.md │ │ ├── 组件通信.md │ │ ├── Props.md │ │ ├── MVVM.md │ │ ├── redux中间件.md │ │ ├── 高阶组件.md │ │ ├── React生命周期.md │ │ └── redux.md │ ├── vue │ │ ├── Babel.md │ │ ├── Vue 各种方法之间的区别.md │ │ ├── Vue动画.md │ │ ├── Promise.md │ │ ├── vue钩子函数.md │ │ ├── Vue路由.md │ │ ├── Vue组件.md │ │ └── vuex.md │ ├── interface │ │ ├── Mind.md │ │ └── TouTiao.md │ ├── algorithm │ │ ├── browser.md │ │ ├── Charpter6.md │ │ └── Charpter4.md │ ├── miniapp │ │ ├── wepy组件通信.md │ │ ├── 小程序组件.md │ │ ├── 小程序组件化.md │ │ ├── WXS.md │ │ ├── 小程序事件.md │ │ └── 小程序路由.md │ ├── README.md │ ├── interview │ │ ├── index.md │ │ └── longhu.md │ ├── guide │ │ ├── getting-started.md │ │ ├── basic-config.md │ │ ├── assets.md │ │ ├── README.md │ │ └── i18n.md │ └── standard │ │ ├── Start.md │ │ ├── Cooperation.md │ │ └── Project.md ├── .vuepress │ ├── public │ │ ├── avatar.jpg │ │ ├── avatar.png │ │ ├── baidu.png │ │ ├── logo.jpg │ │ ├── logo.png │ │ ├── project.jpg │ │ ├── img │ │ │ └── improve.png │ │ ├── algorithm │ │ │ ├── 4.7.png │ │ │ ├── 4.8.png │ │ │ ├── 5.7.png │ │ │ ├── 6.1.png │ │ │ ├── 4.14.png │ │ │ ├── 4.16.png │ │ │ ├── 4.18.png │ │ │ ├── 5.10.png │ │ │ ├── 5.16.png │ │ │ ├── 5.17.png │ │ │ ├── 5.18.png │ │ │ └── 6.13.png │ │ ├── FastStoneEditor.jpg │ │ ├── icons │ │ │ ├── favicon-16x16.png │ │ │ ├── favicon-32x32.png │ │ │ ├── mstile-150x150.png │ │ │ ├── apple-touch-icon.png │ │ │ ├── android-chrome-192x192.png │ │ │ ├── android-chrome-512x512.png │ │ │ ├── apple-touch-icon-60x60.png │ │ │ ├── apple-touch-icon-76x76.png │ │ │ ├── apple-touch-icon-120x120.png │ │ │ ├── apple-touch-icon-152x152.png │ │ │ ├── apple-touch-icon-180x180.png │ │ │ └── msapplication-icon-144x144.png │ │ ├── line-numbers-desktop.png │ │ ├── line-numbers-mobile.gif │ │ └── manifest.json │ └── components │ │ └── Bit.vue ├── README.md └── guide │ ├── getting-started.md │ ├── assets.md │ ├── basic-config.md │ └── README.md ├── scripts ├── deploy-gh.sh └── release.sh ├── .babelrc ├── .npmignore ├── .eslintrc.js ├── README.md ├── .gitignore └── README-cn.md /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/app/.temp/override.styl: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/app/.temp/style.styl: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/assets/css/7.styles.c8b06cc2.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/noop.js: -------------------------------------------------------------------------------- 1 | module.exports = {} 2 | -------------------------------------------------------------------------------- /lib/webpack/noopModule.js: -------------------------------------------------------------------------------- 1 | export default {} 2 | -------------------------------------------------------------------------------- /test/docs-simple/README.md: -------------------------------------------------------------------------------- 1 | # Hello Simple 2 | -------------------------------------------------------------------------------- /lib/app/.temp/enhanceApp.js: -------------------------------------------------------------------------------- 1 | export default function () {} -------------------------------------------------------------------------------- /lib/app/.temp/themeEnhanceApp.js: -------------------------------------------------------------------------------- 1 | export default function () {} -------------------------------------------------------------------------------- /test/prepare/fixtures/docs-simple/README.md: -------------------------------------------------------------------------------- 1 | # Simple Docs 2 | -------------------------------------------------------------------------------- /test/markdown/fragments/code.md: -------------------------------------------------------------------------------- 1 | ``` js 2 | new Vue() 3 | ``` 4 | -------------------------------------------------------------------------------- /test/prepare/fixtures/docs-custom-theme/.vuepress/theme/Layout.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/prepare/fixtures/docs-custom-theme/README.md: -------------------------------------------------------------------------------- 1 | # Simple Docs 2 | -------------------------------------------------------------------------------- /test/prepare/fixtures/docs-simple-config/README.md: -------------------------------------------------------------------------------- 1 | # Simple Docs 2 | -------------------------------------------------------------------------------- /docs/assets/css/4.styles.4c7ddd69.css: -------------------------------------------------------------------------------- 1 | .example_23i3u5eI{color:#41b883} -------------------------------------------------------------------------------- /docs/assets/css/6.styles.7081061c.css: -------------------------------------------------------------------------------- 1 | .example_2R8aKaq3{color:#41b883} -------------------------------------------------------------------------------- /docs/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/logo.jpg -------------------------------------------------------------------------------- /docs/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/logo.png -------------------------------------------------------------------------------- /docs/avatar.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/avatar.jpg -------------------------------------------------------------------------------- /docs/avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/avatar.png -------------------------------------------------------------------------------- /docs/baidu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/baidu.png -------------------------------------------------------------------------------- /docs/project.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/project.jpg -------------------------------------------------------------------------------- /test/markdown/fragments/container-tip.md: -------------------------------------------------------------------------------- 1 | ::: tip 2 | I am a tip 3 | ::: 4 | -------------------------------------------------------------------------------- /src/zh/react/React组件.md: -------------------------------------------------------------------------------- 1 | # React组件 2 | ##### 无状态组件(视图组件) 3 | ##### class 继承 (容器组件) -------------------------------------------------------------------------------- /test/markdown/fragments/container-v-pre.md: -------------------------------------------------------------------------------- 1 | ::: v-pre 2 | I am a v-pre 3 | ::: 4 | -------------------------------------------------------------------------------- /docs/img/improve.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/img/improve.png -------------------------------------------------------------------------------- /test/markdown/fragments/code-snippet.md: -------------------------------------------------------------------------------- 1 | <<< @/test/markdown/fragments/snippet.js 2 | -------------------------------------------------------------------------------- /test/markdown/fragments/container-danger.md: -------------------------------------------------------------------------------- 1 | ::: danger 2 | I am a danger 3 | ::: 4 | -------------------------------------------------------------------------------- /test/markdown/fragments/container-tip-override.md: -------------------------------------------------------------------------------- 1 | ::: tip 提示 2 | I am a tip 3 | ::: 4 | -------------------------------------------------------------------------------- /test/markdown/fragments/container-warning.md: -------------------------------------------------------------------------------- 1 | ::: warning 2 | I am a warning 3 | ::: 4 | -------------------------------------------------------------------------------- /test/markdown/fragments/snippet.js: -------------------------------------------------------------------------------- 1 | export default function () { 2 | // .. 3 | } 4 | -------------------------------------------------------------------------------- /docs/algorithm/4.14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/algorithm/4.14.png -------------------------------------------------------------------------------- /docs/algorithm/4.16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/algorithm/4.16.png -------------------------------------------------------------------------------- /docs/algorithm/4.18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/algorithm/4.18.png -------------------------------------------------------------------------------- /docs/algorithm/4.7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/algorithm/4.7.png -------------------------------------------------------------------------------- /docs/algorithm/4.8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/algorithm/4.8.png -------------------------------------------------------------------------------- /docs/algorithm/5.10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/algorithm/5.10.png -------------------------------------------------------------------------------- /docs/algorithm/5.16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/algorithm/5.16.png -------------------------------------------------------------------------------- /docs/algorithm/5.17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/algorithm/5.17.png -------------------------------------------------------------------------------- /docs/algorithm/5.18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/algorithm/5.18.png -------------------------------------------------------------------------------- /docs/algorithm/5.7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/algorithm/5.7.png -------------------------------------------------------------------------------- /docs/algorithm/6.1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/algorithm/6.1.png -------------------------------------------------------------------------------- /docs/algorithm/6.13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/algorithm/6.13.png -------------------------------------------------------------------------------- /test/markdown/fragments/code-highlightLines-single.md: -------------------------------------------------------------------------------- 1 | ``` js {1} 2 | new Vue() 3 | ``` 4 | -------------------------------------------------------------------------------- /docs/FastStoneEditor.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/FastStoneEditor.jpg -------------------------------------------------------------------------------- /docs/icons/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/icons/favicon-16x16.png -------------------------------------------------------------------------------- /docs/icons/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/icons/favicon-32x32.png -------------------------------------------------------------------------------- /docs/line-numbers-mobile.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/line-numbers-mobile.gif -------------------------------------------------------------------------------- /lib/default-theme/styles/toc.styl: -------------------------------------------------------------------------------- 1 | .table-of-contents 2 | .badge 3 | vertical-align middle 4 | -------------------------------------------------------------------------------- /docs/icons/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/icons/apple-touch-icon.png -------------------------------------------------------------------------------- /docs/icons/mstile-150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/icons/mstile-150x150.png -------------------------------------------------------------------------------- /docs/line-numbers-desktop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/line-numbers-desktop.png -------------------------------------------------------------------------------- /src/.vuepress/public/avatar.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/avatar.jpg -------------------------------------------------------------------------------- /src/.vuepress/public/avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/avatar.png -------------------------------------------------------------------------------- /src/.vuepress/public/baidu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/baidu.png -------------------------------------------------------------------------------- /src/.vuepress/public/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/logo.jpg -------------------------------------------------------------------------------- /src/.vuepress/public/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/logo.png -------------------------------------------------------------------------------- /docs/assets/js/7.c8b06cc2.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[7],{147:function(n,w,o){}}]); -------------------------------------------------------------------------------- /src/.vuepress/public/project.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/project.jpg -------------------------------------------------------------------------------- /test/markdown/fragments/code-snippet-highlightLines-multiple.md: -------------------------------------------------------------------------------- 1 | <<< @/test/markdown/fragments/snippet.js{1-3} 2 | -------------------------------------------------------------------------------- /test/markdown/fragments/code-snippet-highlightLines-single.md: -------------------------------------------------------------------------------- 1 | <<< @/test/markdown/fragments/snippet.js{1,3} 2 | -------------------------------------------------------------------------------- /src/.vuepress/public/img/improve.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/img/improve.png -------------------------------------------------------------------------------- /docs/icons/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/icons/android-chrome-192x192.png -------------------------------------------------------------------------------- /docs/icons/android-chrome-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/icons/android-chrome-512x512.png -------------------------------------------------------------------------------- /docs/icons/apple-touch-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/icons/apple-touch-icon-60x60.png -------------------------------------------------------------------------------- /docs/icons/apple-touch-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/icons/apple-touch-icon-76x76.png -------------------------------------------------------------------------------- /src/.vuepress/public/algorithm/4.7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/algorithm/4.7.png -------------------------------------------------------------------------------- /src/.vuepress/public/algorithm/4.8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/algorithm/4.8.png -------------------------------------------------------------------------------- /src/.vuepress/public/algorithm/5.7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/algorithm/5.7.png -------------------------------------------------------------------------------- /src/.vuepress/public/algorithm/6.1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/algorithm/6.1.png -------------------------------------------------------------------------------- /docs/icons/apple-touch-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/icons/apple-touch-icon-120x120.png -------------------------------------------------------------------------------- /docs/icons/apple-touch-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/icons/apple-touch-icon-152x152.png -------------------------------------------------------------------------------- /docs/icons/apple-touch-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/icons/apple-touch-icon-180x180.png -------------------------------------------------------------------------------- /docs/icons/msapplication-icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/docs/icons/msapplication-icon-144x144.png -------------------------------------------------------------------------------- /scripts/deploy-gh.sh: -------------------------------------------------------------------------------- 1 | cd / 2 | git add -A 3 | git commit -m 'deploy' 4 | echo "finish commit" 5 | git push -f origin master 6 | -------------------------------------------------------------------------------- /src/.vuepress/public/FastStoneEditor.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/FastStoneEditor.jpg -------------------------------------------------------------------------------- /src/.vuepress/public/algorithm/4.14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/algorithm/4.14.png -------------------------------------------------------------------------------- /src/.vuepress/public/algorithm/4.16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/algorithm/4.16.png -------------------------------------------------------------------------------- /src/.vuepress/public/algorithm/4.18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/algorithm/4.18.png -------------------------------------------------------------------------------- /src/.vuepress/public/algorithm/5.10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/algorithm/5.10.png -------------------------------------------------------------------------------- /src/.vuepress/public/algorithm/5.16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/algorithm/5.16.png -------------------------------------------------------------------------------- /src/.vuepress/public/algorithm/5.17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/algorithm/5.17.png -------------------------------------------------------------------------------- /src/.vuepress/public/algorithm/5.18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/algorithm/5.18.png -------------------------------------------------------------------------------- /src/.vuepress/public/algorithm/6.13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/algorithm/6.13.png -------------------------------------------------------------------------------- /src/.vuepress/public/icons/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/icons/favicon-16x16.png -------------------------------------------------------------------------------- /src/.vuepress/public/icons/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/icons/favicon-32x32.png -------------------------------------------------------------------------------- /src/.vuepress/public/icons/mstile-150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/icons/mstile-150x150.png -------------------------------------------------------------------------------- /src/.vuepress/public/line-numbers-desktop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/line-numbers-desktop.png -------------------------------------------------------------------------------- /src/.vuepress/public/line-numbers-mobile.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/line-numbers-mobile.gif -------------------------------------------------------------------------------- /src/.vuepress/public/icons/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/icons/apple-touch-icon.png -------------------------------------------------------------------------------- /src/.vuepress/public/icons/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/icons/android-chrome-192x192.png -------------------------------------------------------------------------------- /src/.vuepress/public/icons/android-chrome-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/icons/android-chrome-512x512.png -------------------------------------------------------------------------------- /src/.vuepress/public/icons/apple-touch-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/icons/apple-touch-icon-60x60.png -------------------------------------------------------------------------------- /src/.vuepress/public/icons/apple-touch-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/icons/apple-touch-icon-76x76.png -------------------------------------------------------------------------------- /src/.vuepress/public/icons/apple-touch-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/icons/apple-touch-icon-120x120.png -------------------------------------------------------------------------------- /src/.vuepress/public/icons/apple-touch-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/icons/apple-touch-icon-152x152.png -------------------------------------------------------------------------------- /src/.vuepress/public/icons/apple-touch-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/icons/apple-touch-icon-180x180.png -------------------------------------------------------------------------------- /src/.vuepress/public/icons/msapplication-icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1z2s/study/HEAD/src/.vuepress/public/icons/msapplication-icon-144x144.png -------------------------------------------------------------------------------- /test/prepare/fixtures/docs-custom-theme/.vuepress/config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | title: 'Hello VuePress', 3 | description: 'Just playing around' 4 | } 5 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | exports.dev = require('./dev') 2 | exports.build = require('./build') 3 | exports.eject = require('./eject') 4 | Object.assign(exports, require('./util')) 5 | -------------------------------------------------------------------------------- /test/markdown/fragments/code-highlightLines-multiple.md: -------------------------------------------------------------------------------- 1 | ``` js {1-2,4-5} 2 | const app = new Vue({ 3 | render, 4 | router 5 | }) 6 | 7 | app.$mount('#app') 8 | ``` 9 | -------------------------------------------------------------------------------- /test/markdown/fragments/hoist.md: -------------------------------------------------------------------------------- 1 | # H1 2 | 3 | 4 | 9 | 10 | ## H2 11 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "test": { 4 | "presets": [ 5 | ["@babel/preset-env", { "targets": { "node": 8 }}] 6 | ] 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /lib/app/store.js: -------------------------------------------------------------------------------- 1 | // It is not yet time to use Vuex to manage the global state 2 | // singleton object as a global store. 3 | const state = { 4 | disableScrollBehavior: false 5 | } 6 | 7 | export default state 8 | -------------------------------------------------------------------------------- /lib/app/root-mixins/index.js: -------------------------------------------------------------------------------- 1 | import updateMeta from './updateMeta' 2 | import activeHeaderLinks from '@activeHeaderLinks' 3 | 4 | export default [ 5 | updateMeta, // required 6 | activeHeaderLinks // optional 7 | ] 8 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # Basic 2 | *.log 3 | .temp 4 | vuepress 5 | art 6 | docs 7 | .eslintrc.js 8 | yarn.lock 9 | TODOs.md 10 | .github 11 | .idea 12 | 13 | # CI related 14 | scripts 15 | 16 | # Test related 17 | test 18 | .babelrc 19 | -------------------------------------------------------------------------------- /lib/default-theme/search.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: [ 4 | 'plugin:vue-libs/recommended', 5 | 'plugin:jest/recommended' 6 | ], 7 | rules: { 8 | indent: ['error', 2, { MemberExpression: 'off' }] 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/zh/react/JSX.md: -------------------------------------------------------------------------------- 1 | # JSX 2 | #### 1、jsx是什么? 3 | - React 使用 JSX 来替代常规的 JavaScript 4 | - JSX 是一个看起来很像 XML 的 JavaScript 语法扩展 5 | - 我们不需要一定使用 JSX,但它有以下优点 6 | 1. > JSX 执行更快,因为它在编译为 JavaScript 代码后进行了优化 7 | 1. > 它是类型安全的,在编译过程中就能发现错误 8 | 1. > 使用 JSX 编写模板更加简单快速 -------------------------------------------------------------------------------- /docs/assets/img/search.683d46b0.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/default-theme/styles/wrapper.styl: -------------------------------------------------------------------------------- 1 | $wrapper 2 | max-width $contentWidth 3 | margin 0 auto 4 | padding 2rem 2.5rem 5 | @media (max-width: $MQNarrow) 6 | padding 2rem 7 | @media (max-width: $MQMobileNarrow) 8 | padding 1.5rem 9 | 10 | -------------------------------------------------------------------------------- /docs/assets/css/3.styles.e7495a9d.css: -------------------------------------------------------------------------------- 1 | @media screen and (min-width:719px){.line-numbers-mobile-snap{display:none}}@media screen and (max-width:719px){.line-numbers-desktop-snap{display:none}.line-numbers-mobile-snap{max-width:none!important;margin:0 -1.5rem;width:100vw}} -------------------------------------------------------------------------------- /docs/assets/css/5.styles.d250c3e3.css: -------------------------------------------------------------------------------- 1 | @media screen and (min-width:719px){.line-numbers-mobile-snap{display:none}}@media screen and (max-width:719px){.line-numbers-desktop-snap{display:none}.line-numbers-mobile-snap{max-width:none!important;margin:0 -1.5rem;width:100vw}} -------------------------------------------------------------------------------- /lib/util/shared.js: -------------------------------------------------------------------------------- 1 | exports.compose = (...processors) => { 2 | if (processors.length === 0) return input => input 3 | if (processors.length === 1) return processors[0] 4 | return processors.reduce((prev, next) => { 5 | return (...args) => next(prev(...args)) 6 | }) 7 | } 8 | -------------------------------------------------------------------------------- /test/prepare/fixtures/docs-simple-config/.vuepress/config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | title: 'Hello VuePress', 3 | description: 'Just playing around', 4 | dest: 'vuepress', 5 | base: 'vuepress', 6 | head: [ 7 | ['link', { rel: 'icon', href: '/logo.png' }] 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /docs/assets/css/2.styles.58c85033.css: -------------------------------------------------------------------------------- 1 | .bit-sponsor{font-weight:600;background-color:#f3f6f8;padding:.6em 1.2em;border-radius:8px;display:inline-block;margin:1em 0!important}.bit-sponsor a{color:#999}.bit-sponsor img{height:40px;margin-left:15px}.bit-sponsor img,.bit-sponsor span{vertical-align:middle} -------------------------------------------------------------------------------- /lib/app/index.dev.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | -------------------------------------------------------------------------------- /src/zh/react/组件通信.md: -------------------------------------------------------------------------------- 1 | # 组件通信 2 | #### 需要组件之进行通信的几种情况 3 | - 父组件向子组件通信 4 | - 子组件向父组件通信 5 | - 跨级组件通信 6 | - 没有嵌套关系组件之间的通信 7 | ##### 1、父组件向子组件通信 8 | - 通过props 9 | ##### 2、子组件向父组件通信 10 | - 利用回调函数 11 | - 利用自定义事件机制 12 | ##### 3、 跨级组件通信 13 | - 层层组件传递props 14 | - 使用context 15 | ##### 4、没有嵌套关系组件之间的通信 16 | - 使用自定义事件机制 -------------------------------------------------------------------------------- /lib/app/components/ClientOnly.js: -------------------------------------------------------------------------------- 1 | export default { 2 | functional: true, 3 | render (h, { parent, children }) { 4 | if (parent._isMounted) { 5 | return children 6 | } else { 7 | parent.$once('hook:mounted', () => { 8 | parent.$forceUpdate() 9 | }) 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/markdown/__snapshots__/highlight.spec.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`highlight should highlight code 1`] = ` 4 |
new Vue()
5 | 
6 | `; 7 | -------------------------------------------------------------------------------- /src/zh/vue/Babel.md: -------------------------------------------------------------------------------- 1 | # Babel 2 | #### 1、Babel 3 | - 是javascript的编译器/解码器/转码器/解析器 4 | 5 | #### 2、配置 6 | - .babelrc 7 | 8 | ``` 9 | 命令: 10 | babel ./index.js -o ./_index.js 11 | 下包: 12 | cnpm install --save-dev babel-cli babel-preset-env 13 | 14 | 15 | { 16 | "presets": [ 17 | "env" 18 | ] 19 | } 20 | 21 | babel-loader // es6转es5 22 | ``` 23 | -------------------------------------------------------------------------------- /lib/app/components/Content.js: -------------------------------------------------------------------------------- 1 | export default { 2 | functional: true, 3 | 4 | props: { 5 | custom: { 6 | type: Boolean, 7 | default: true 8 | } 9 | }, 10 | 11 | render (h, { parent, props, data }) { 12 | return h(parent.$page.key, { 13 | class: [props.custom ? 'custom' : '', data.class, data.staticClass], 14 | style: data.style 15 | }) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/zh/react/Props.md: -------------------------------------------------------------------------------- 1 | # Props 2 | #### 1、和props相关 3 | - 只读,不准修改 4 | - componentWillReceiveProps / 生命周期 5 | - propTypes 6 | - defaultProps 7 | - children 8 | #### 2、类型检查 9 | 10 | ``` 11 | import PropTypes from 'prop-types'; 12 | 13 | List.propTypes = { 14 | list:PropTypes.array/object/number/string 15 | } 16 | ``` 17 | #### 3、默认值 18 | ``` 19 | List.defaultProps = { 20 | list:[{},{},{}] 21 | } 22 | ``` 23 | -------------------------------------------------------------------------------- /lib/app/serverEntry.js: -------------------------------------------------------------------------------- 1 | import { createApp } from './app' 2 | 3 | export default context => new Promise((resolve, reject) => { 4 | const { app, router } = createApp() 5 | const { url } = context 6 | const { fullPath } = router.resolve(url).route 7 | 8 | if (fullPath !== url) { 9 | return reject({ url: fullPath }) 10 | } 11 | 12 | router.push(url) 13 | router.onReady(() => resolve(app)) 14 | }) 15 | -------------------------------------------------------------------------------- /lib/service-worker/skip-waiting.js: -------------------------------------------------------------------------------- 1 | addEventListener('message', event => { 2 | const replyPort = event.ports[0] 3 | const message = event.data 4 | if (replyPort && message && message.type === 'skip-waiting') { 5 | event.waitUntil( 6 | self.skipWaiting().then( 7 | () => replyPort.postMessage({ error: null }), 8 | error => replyPort.postMessage({ error }) 9 | ) 10 | ) 11 | } 12 | }) 13 | -------------------------------------------------------------------------------- /lib/markdown/hoist.js: -------------------------------------------------------------------------------- 1 | module.exports = md => { 2 | const RE = /^<(script|style)(?=(\s|>|$))/i 3 | 4 | md.renderer.rules.html_block = (tokens, idx) => { 5 | const content = tokens[idx].content 6 | const hoistedTags = md.__data.hoistedTags || (md.__data.hoistedTags = []) 7 | if (RE.test(content.trim())) { 8 | hoistedTags.push(content) 9 | return '' 10 | } else { 11 | return content 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib/app/util.js: -------------------------------------------------------------------------------- 1 | export function injectMixins (options, mixins) { 2 | if (!options.mixins) { 3 | options.mixins = [] 4 | } 5 | options.mixins.push(...mixins) 6 | } 7 | 8 | export function findPageForPath (pages, path) { 9 | for (let i = 0; i < pages.length; i++) { 10 | const page = pages[i] 11 | if (page.path === path) { 12 | return page 13 | } 14 | } 15 | return { 16 | path: '', 17 | frontmatter: {} 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /docs/assets/js/1.445f32b6.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[1],{135:function(t,n,e){},141:function(t,n,e){"use strict";var a=e(135);e.n(a).a},184:function(t,n,e){"use strict";e.r(n);var a={functional:!0,props:{type:{type:String,default:"tip"},text:String,vertical:{type:String,default:"top"}},render:function(t,n){var e=n.props,a=n.slots;return t("span",{class:["badge",e.type,e.vertical]},e.text||a().default)}},r=(e(141),e(0)),i=Object(r.a)(a,void 0,void 0,!1,null,"97b6395a",null);n.default=i.exports}}]); -------------------------------------------------------------------------------- /docs/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "VuePress", 3 | "short_name": "VuePress", 4 | "icons": [ 5 | { 6 | "src": "/icons/android-chrome-192x192.png", 7 | "sizes": "192x192", 8 | "type": "image/png" 9 | }, 10 | { 11 | "src": "/icons/android-chrome-512x512.png", 12 | "sizes": "512x512", 13 | "type": "image/png" 14 | } 15 | ], 16 | "start_url": "/index.html", 17 | "display": "standalone", 18 | "background_color": "#fff", 19 | "theme_color": "#3eaf7c" 20 | } 21 | -------------------------------------------------------------------------------- /test/hoc.js: -------------------------------------------------------------------------------- 1 | const Component = { 2 | props: ['name'], 3 | render (h) { 4 | return h('p', { 5 | class: ['component', this.name] 6 | }, this.name) 7 | } 8 | } 9 | 10 | // When the child component is a pure presentation component, 11 | // we want to be able to display a sub-component with minimal info, 12 | // rather than stubbing it directly. 13 | export function mockComponent (name) { 14 | return { 15 | render (h) { 16 | return h(Component, { props: { name }}) 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/markdown/highlight.spec.js: -------------------------------------------------------------------------------- 1 | import { Md, getFragment } from './util' 2 | import highlight from '@/markdown/highlight.js' 3 | 4 | const md = Md() 5 | const mdH = Md().set({ highlight }) 6 | 7 | describe('highlight', () => { 8 | test('should highlight code', async () => { 9 | const input = await getFragment('code') 10 | const output1 = md.render(input) 11 | const output2 = mdH.render(input) 12 | expect(output1 === output2).toBe(false) 13 | expect(output2).toMatchSnapshot() 14 | }) 15 | }) 16 | -------------------------------------------------------------------------------- /src/.vuepress/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "VuePress", 3 | "short_name": "VuePress", 4 | "icons": [ 5 | { 6 | "src": "/icons/android-chrome-192x192.png", 7 | "sizes": "192x192", 8 | "type": "image/png" 9 | }, 10 | { 11 | "src": "/icons/android-chrome-512x512.png", 12 | "sizes": "512x512", 13 | "type": "image/png" 14 | } 15 | ], 16 | "start_url": "/index.html", 17 | "display": "standalone", 18 | "background_color": "#fff", 19 | "theme_color": "#3eaf7c" 20 | } 21 | -------------------------------------------------------------------------------- /docs/assets/css/1.styles.445f32b6.css: -------------------------------------------------------------------------------- 1 | .badge[data-v-97b6395a]{display:inline-block;font-size:14px;height:18px;line-height:18px;border-radius:3px;padding:0 6px;color:#fff;margin-right:5px;background-color:#42b983}.badge.middle[data-v-97b6395a]{vertical-align:middle}.badge.top[data-v-97b6395a]{vertical-align:top}.badge.green[data-v-97b6395a],.badge.tip[data-v-97b6395a]{background-color:#42b983}.badge.error[data-v-97b6395a]{background-color:#da5961}.badge.warn[data-v-97b6395a],.badge.warning[data-v-97b6395a],.badge.yellow[data-v-97b6395a]{background-color:#e7c000} -------------------------------------------------------------------------------- /test/markdown/containers.spec.js: -------------------------------------------------------------------------------- 1 | import { Md, getFragment } from './util' 2 | import containers from '@/markdown/containers.js' 3 | 4 | const mdC = Md().use(containers) 5 | 6 | describe('containers', () => { 7 | const containerLabels = ['tip', 'tip-override', 'warning', 'danger', 'v-pre'] 8 | containerLabels.forEach(label => { 9 | test(label, async () => { 10 | const input = await getFragment(`container-${label}`) 11 | const output = mdC.render(input) 12 | expect(output).toMatchSnapshot() 13 | }) 14 | }) 15 | }) 16 | -------------------------------------------------------------------------------- /test/markdown/util.js: -------------------------------------------------------------------------------- 1 | import fs from 'fs-extra' 2 | import LRU from 'lru-cache' 3 | import path from 'path' 4 | 5 | const cache = LRU({ max: 1000 }) 6 | 7 | export function Md () { 8 | return require('markdown-it')() 9 | } 10 | 11 | export async function getFragment (name) { 12 | let content = cache.get(name) 13 | if (content) { 14 | return content 15 | } 16 | const target = path.resolve(__dirname, `fragments/${name}.md`) 17 | content = await fs.readFile(target, 'utf-8') 18 | cache.set(name, content) 19 | return content 20 | } 21 | -------------------------------------------------------------------------------- /src/zh/interface/Mind.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 思维导图版知识点总结 3 | sidebar: auto 4 | sidebarDepth: 2 5 | --- 6 | # 思维导图版知识点总结 7 | 8 | ## Vue 9 | ![vue](http://assets.processon.com/chart_image/5af6a37ae4b0a0f0f1a05a36.png) 10 | 11 | ## React 12 | ![react](http://assets.processon.com/chart_image/5b33428ae4b0a8a7ffb98bd7.png?_=1552542663250) 13 | 14 | ## 阶段一 15 | ![实训一](http://assets.processon.com/chart_image/5bac8350e4b0bd4db94e9514.png?_=1552542696718) 16 | 17 | ## 阶段二 18 | ![实训二](http://assets.processon.com/chart_image/5bc0198fe4b06fc64b17fa15.png?_=1552542798104) 19 | -------------------------------------------------------------------------------- /lib/default-theme/styles/config.styl: -------------------------------------------------------------------------------- 1 | // colors 2 | $accentColor = #3eaf7c 3 | $textColor = #2c3e50 4 | $borderColor = #eaecef 5 | $codeBgColor = #282c34 6 | $arrowBgColor = #ccc 7 | 8 | // layout 9 | $navbarHeight = 3.6rem 10 | $sidebarWidth = 20rem 11 | $contentWidth = 740px 12 | 13 | // responsive breakpoints 14 | $MQNarrow = 959px 15 | $MQMobile = 719px 16 | $MQMobileNarrow = 419px 17 | 18 | // code 19 | $lineNumbersWrapperWidth = 3.5rem 20 | $codeLang = js ts html md vue css sass scss less stylus go java c sh yaml py 21 | 22 | @import '~@temp/override.styl' 23 | -------------------------------------------------------------------------------- /src/zh/vue/Vue 各种方法之间的区别.md: -------------------------------------------------------------------------------- 1 | # Vue一些对比 2 | #### 一、methods和computed 3 | - computed是计算属性,methods是方法。 4 | - computed计算属性是基于它们的依赖进行==缓存==的 5 | - computed只有在它的相关依赖发生改变时才会重新求值 6 | - 而对于method ,只要发生重新渲染,method 调用==总会==执行该函数 7 | - ==总之:数据量大,需要缓存的时候用computed;每次确实需要重新加载,不需要缓存时用methods== 8 | #### 二、computed和watch 9 | - 计算属性是==计算属性==,==侦听器watch==是侦听器watch 10 | - 侦听器watch是侦听一个特定的值,当该值变化时执行特定的函数 11 | #### 三、$router和$route 12 | - router为VueRouter的实例,相当于一个全局的路由器对象,里面含有很多属性和子对象 13 | - route相当于当前正在跳转的路由对象。。可以从里面获取name,path,params,query等 14 | - 打印this.$route和this.$router,==两个同时存在==。 15 | - 两者传参方式相同 -------------------------------------------------------------------------------- /src/zh/vue/Vue动画.md: -------------------------------------------------------------------------------- 1 | # Vue动画 2 | #### 1、transition 3 | 1. name="" -> 手写 4 | 2. animate.css 5 | 3. velocity.js 6 | #### 2、进入动画 从0-1 7 | 1. v-enter // 进入前 8 | 2. v-enter-active // 定义进入过渡生效时的状态 9 | 3. v-enter-to // 定义进入过渡结束时的状态 10 | #### 3、离开动画 从1-0 11 | 1. v-leave // 离开前 12 | 2. v-leave-active // 离开中 13 | 3. v-leave-to // 离开后 14 | #### 4、过渡持续时间 15 | - :duration='1000' 16 | - :duration='{enter:'1000',leave:'1000'}' 17 | #### 5、JavaScript钩子 18 | 19 | ``` 20 | v-on:before-enter 21 | v-on:enter 22 | v-on:after-enter 23 | v-on:enter-cancelled // 取消动画(删除) 24 | ``` 25 | 26 | -------------------------------------------------------------------------------- /src/zh/react/MVVM.md: -------------------------------------------------------------------------------- 1 | # MVVM 2 | #### 1、MVVM是什么? 3 | 1. MVVM是Model-View-ViewModel的简写 4 | 2. 它本质上是MVC 的改进版 5 | 3. MVVM(Model-View-ViewModel)框架的由来是MVP(Model-View-Presenter)模式与WPF结合的应用方式时发展演变过来的一种新型架构框架 6 | #### 2、MVVM优点 7 | 8 | - > MVVM模式和MVC模式一样,主要目的是分离视图(View)和模型(Model),有几大优点 9 | 10 | 1. **低耦合**:视图(View)可以独立于Model变化和修改,一个ViewModel可以绑定到不同的"View"上,当View变化的时候Model可以不变,当Model变化的时候View也可以不变 11 | 2. **可重用性**:你可以把一些视图逻辑放在一个ViewModel里面,让很多view重用这段视图逻辑 12 | 3. **独立开发**:开发人员可以专注于业务逻辑和数据的开发(ViewModel),设计人员可以专注于页面设计,使用Expression Blend可以很容易设计界面并生成xml代码 13 | 4. **可测试**:界面素来是比较难于测试的,而现在测试可以针对ViewModel来写 -------------------------------------------------------------------------------- /lib/default-theme/NotFound.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 27 | -------------------------------------------------------------------------------- /lib/app/components/OutboundLink.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 13 | -------------------------------------------------------------------------------- /test/markdown/__snapshots__/highlightLines.spec.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`highlightLines highlight multiple lines 1`] = ` 4 |
5 |
 
6 |
 
7 |
8 |
 
9 |
 
10 |
11 |
12 |
const app = new Vue({ render, router }) app.$mount('#app') 13 | `; 14 | 15 | exports[`highlightLines highlight single line 1`] = ` 16 |
17 |
 
18 |
19 |
new Vue() 20 | `; 21 | -------------------------------------------------------------------------------- /lib/webpack/HeadPlugin.js: -------------------------------------------------------------------------------- 1 | const { normalizeHeadTag } = require('../util') 2 | 3 | module.exports = class SiteDataPlugin { 4 | constructor ({ tags }) { 5 | this.tags = tags 6 | } 7 | 8 | apply (compiler) { 9 | compiler.hooks.compilation.tap('vuepress-site-data', compilation => { 10 | compilation.hooks.htmlWebpackPluginAlterAssetTags.tapAsync('vuepress-site-data', (data, cb) => { 11 | try { 12 | this.tags.forEach(tag => { 13 | data.head.push(normalizeHeadTag(tag)) 14 | }) 15 | } catch (e) { 16 | return cb(e) 17 | } 18 | cb(null, data) 19 | }) 20 | }) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/zh/algorithm/browser.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar: auto 3 | sidebarDepth: 2 4 | --- 5 | 6 | # 浏览器 7 | ### 浏览器历史 8 | 最开始是3w浏览器,刚出来就很快死掉了,后来就出来了Mosaic浏览器,它是第一个普遍使用并且可以显示图片的网页浏览器。 9 | 10 | ### 什么是浏览器 11 | 浏览器分为两部分 ,一是shell部分(外壳),二是内核;用户可以看到和操作的部分是外壳,看不到的能够处理代码并且可以把代码完整显示出来的是内核部分,内核是最主要的一部分。 12 | 13 | ### 内核 14 | 内核大致分为两大部分,一是渲染引擎,二是js引擎;渲染引擎主要负责的是html和css一些基础语法的识别以及更高效的去绘图页面;js引擎越来越独立主要是负责JavaScript的 15 | 16 | ### 主流浏览器机器内核(专业知识) 17 | | 浏览器 | 内核 | 18 | | -------- | -----: | 19 | | IE | trident | 20 | | Chrome | webkit/blink | 21 | | firefox | Gecko | 22 | | opera | Presto | 23 | | safari | webkit | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /lib/default-theme/styles/arrow.styl: -------------------------------------------------------------------------------- 1 | @require './config' 2 | 3 | .arrow 4 | display inline-block 5 | width 0 6 | height 0 7 | &.up 8 | border-left 4px solid transparent 9 | border-right 4px solid transparent 10 | border-bottom 6px solid $arrowBgColor 11 | &.down 12 | border-left 4px solid transparent 13 | border-right 4px solid transparent 14 | border-top 6px solid $arrowBgColor 15 | &.right 16 | border-top 4px solid transparent 17 | border-bottom 4px solid transparent 18 | border-left 6px solid $arrowBgColor 19 | &.left 20 | border-top 4px solid transparent 21 | border-bottom 4px solid transparent 22 | border-right 6px solid $arrowBgColor 23 | -------------------------------------------------------------------------------- /test/markdown/__snapshots__/hoist.spec.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`hoist Should keep script and style when not using hoist 1`] = ` 4 |

H1

5 | 6 | 11 |

H2

12 | `; 13 | 14 | exports[`hoist Should miss script and style when using hoist 1`] = ` 15 |

H1

16 |

H2

17 | `; 18 | 19 | exports[`hoist Should miss script and style when using hoist 2`] = ` 20 | Object { 21 | "hoistedTags": Array [ 22 | , 23 | , 28 | ], 29 | } 30 | `; 31 | -------------------------------------------------------------------------------- /docs/assets/js/2.58c85033.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[2],{136:function(t,e,s){},142:function(t,e,s){"use strict";var u=s(136);s.n(u).a},211:function(t,e,s){"use strict";s.r(e);s(142);var u=s(0),n=Object(u.a)({},function(){this.$createElement;this._self._c;return this._e()},[function(){var t=this.$createElement,e=this._self._c||t;return e("a",{attrs:{href:"https://www.bitsrc.io/?utm_source=vue&utm_medium=vue&utm_campaign=vue&utm_term=vue&utm_content=vue",target:"_blank"}},[e("span",[this._v("This project is sponsored by")]),this._v(" "),e("img",{attrs:{alt:"bit",src:"https://raw.githubusercontent.com/vuejs/vuejs.org/master/themes/vue/source/images/bit-wide.png"}})])}],!1,null,null,null);e.default=n.exports}}]); -------------------------------------------------------------------------------- /src/zh/miniapp/wepy组件通信.md: -------------------------------------------------------------------------------- 1 | # 组件通信 2 | ##### $emit 3 | > 子向父通信 4 | ##### $broadcast 5 | > 父向子通信 6 | ##### 父子通信:父组件传递数据给子组件 7 | **1、通过props传值** 8 | 1. 如果需要传递动态属性值需要添加.sync修饰符 9 | 1. 如果要在子组件中修改父组件数据需要在接受的时候添加 twoWay: true 10 | 1. 如果需要数据双向绑定需要(.sync 和 twoWay 同时) 11 | 12 | **2、实用$broadcast将数据广播到所有子组件中** 13 | ##### 子父通信:子组件传递数据给父组件 14 | 1. 在父组件中events中定义事件,在子组件$emit触发 (推荐) 15 | 1. 在父组件methods中添加方法,在子组件中this.$invoke('../', '函数名称') 16 | 1. 在子组件中通过this.$parent获取到父组件实例,调用父组件回调函数给父组件发送数据 17 | ##### 同级:A、B两个同级组件的数据发送 18 | 1. 在A组件中通过this.$invoke('../B', '函数名称') 调用B组件中的回调函数传递数据 19 | 1. 将数据发送到父组件,父组件在传递给另一个子组件(代理方式) 20 | 1. 自己封装一个发布订阅器(eventbus) 21 | ##### 跨级: 22 | 1. 逐层传递 23 | 1. this.$invoke('组件路径', '函数名称') 24 | 25 | **使用redux可以做所有的数据管理** -------------------------------------------------------------------------------- /test/jest.config.js: -------------------------------------------------------------------------------- 1 | // https://github.com/facebook/jest/tree/master/packages/babel-jest 2 | // TODO remove 'babel-core@^7.0.0-0' when babel-jest can work with '@babel/core' 3 | 4 | const path = require('path') 5 | 6 | module.exports = { 7 | rootDir: path.resolve(__dirname, '..'), 8 | verbose: true, 9 | testURL: 'http://localhost/', 10 | moduleFileExtensions: [ 11 | 'js', 12 | 'vue' 13 | ], 14 | moduleNameMapper: { 15 | '^@/(.*)$': '/lib/$1' 16 | }, 17 | transform: { 18 | '^.+\\.js$': '/node_modules/babel-jest', 19 | '.*\\.(vue)$': '/node_modules/vue-jest' 20 | }, 21 | snapshotSerializers: [ 22 | '/node_modules/jest-serializer-vue' 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /lib/eject.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs-extra') 2 | const path = require('path') 3 | const chalk = require('chalk') 4 | const logger = require('./util/logger') 5 | 6 | module.exports = async (dir) => { 7 | const source = path.resolve(__dirname, 'default-theme') 8 | const target = path.resolve(dir, '.vuepress/theme') 9 | await fs.copy(source, target) 10 | // remove the import to default theme override 11 | const styleConfig = path.resolve(target, 'styles/config.styl') 12 | const content = await fs.readFile(styleConfig, 'utf-8') 13 | const transformed = content.split('\n').slice(0, -2).join('\n') 14 | await fs.writeFile(styleConfig, transformed) 15 | logger.success(`\nCopied default theme into ${chalk.cyan(target)}.\n`) 16 | } 17 | -------------------------------------------------------------------------------- /lib/default-theme/DropdownTransition.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 28 | 29 | 34 | -------------------------------------------------------------------------------- /test/markdown/__snapshots__/link.spec.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`link should render external links correctly 1`] = ` 4 |

5 | vue 6 | 7 | 8 |

9 | `; 10 | 11 | exports[`link should render external links correctly 2`] = ` 12 |

13 | vue 14 | 15 | 16 |

17 | `; 18 | 19 | exports[`link should render external links correctly 3`] = ` 20 |

21 | some link with code 22 | 23 | 24 |

25 | `; 26 | -------------------------------------------------------------------------------- /test/prepare.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | const fs = require('fs-extra') 3 | const prepare = require('../lib/prepare') 4 | const logger = require('../lib/util/logger') 5 | 6 | const tempPath = path.resolve(__dirname, '.temp') 7 | const siteDatePath = path.resolve(__dirname, '../lib/app/.temp/siteData.js') 8 | 9 | async function prepareForTest () { 10 | await fs.ensureDir(tempPath) 11 | 12 | await prepare(path.resolve(__dirname, '../docs')) 13 | await fs.copy(siteDatePath, path.join(tempPath, 'siteData-i18n.js')) 14 | 15 | await prepare(path.resolve(__dirname, 'docs-simple')) 16 | await fs.copy(siteDatePath, path.join(tempPath, 'siteData-simple.js')) 17 | } 18 | 19 | prepareForTest().then(() => { 20 | logger.wait('Preparing for testing ...') 21 | }) 22 | -------------------------------------------------------------------------------- /src/zh/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | home: true 3 | heroImage: /hero.png 4 | actionText: 快速上手 → 5 | actionLink: /zh/guide/ 6 | features: 7 | - title: 简洁至上 8 | details: 以 Markdown 为中心的项目结构,以最少的配置帮助你专注于写作。 9 | - title: Vue驱动 10 | details: 享受 Vue + webpack 的开发体验,可以在 Markdown 中使用 Vue 组件,又可以使用 Vue 来开发自定义主题。 11 | - title: 高性能 12 | details: VuePress 会为每个页面预渲染生成静态的 HTML,同时,每个页面被加载的时候,将作为 SPA 运行。 13 | footer: MIT Licensed | Copyright © 2018-present Evan You 14 | --- 15 | 16 | ### 像数 1, 2, 3 一样容易 17 | 18 | ``` bash 19 | # 安装 20 | yarn global add vuepress # 或者:npm install -g vuepress 21 | 22 | # 新建一个 markdown 文件 23 | echo '# Hello VuePress!' > README.md 24 | 25 | # 开始写作 26 | vuepress dev . 27 | 28 | # 构建静态文件 29 | vuepress build . 30 | ``` 31 | 32 | ::: warning 注意 33 | 请确保你的 Node.js 版本 >= 8。 34 | ::: 35 | -------------------------------------------------------------------------------- /lib/markdown/preWrapper.js: -------------------------------------------------------------------------------- 1 | // markdown-it plugin for wrapping
 ... 
. 2 | // 3 | // If your plugin was chained before preWrapper, you can add additional eleemnt directly. 4 | // If your plugin was chained after preWrapper, you can use these slots: 5 | // 1. 6 | // 2. 7 | // 3. 8 | // 4. 9 | 10 | module.exports = md => { 11 | const fence = md.renderer.rules.fence 12 | md.renderer.rules.fence = (...args) => { 13 | const [tokens, idx] = args 14 | const token = tokens[idx] 15 | const rawCode = fence(...args) 16 | return `
` + 17 | `${rawCode}
` 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/.vuepress/components/Bit.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 26 | -------------------------------------------------------------------------------- /lib/default-theme/styles/custom-blocks.styl: -------------------------------------------------------------------------------- 1 | .custom-block 2 | .custom-block-title 3 | font-weight 600 4 | margin-bottom -0.4rem 5 | &.tip, &.warning, &.danger 6 | padding .1rem 1.5rem 7 | border-left-width .5rem 8 | border-left-style solid 9 | margin 1rem 0 10 | &.tip 11 | background-color #f3f5f7 12 | border-color #42b983 13 | &.warning 14 | background-color rgba(255,229,100,.3) 15 | border-color darken(#ffe564, 35%) 16 | color darken(#ffe564, 70%) 17 | .custom-block-title 18 | color darken(#ffe564, 50%) 19 | a 20 | color $textColor 21 | &.danger 22 | background-color #ffe6e6 23 | border-color darken(red, 20%) 24 | color darken(red, 70%) 25 | .custom-block-title 26 | color darken(red, 40%) 27 | a 28 | color $textColor 29 | -------------------------------------------------------------------------------- /test/markdown/hoist.spec.js: -------------------------------------------------------------------------------- 1 | import { Md, getFragment } from './util' 2 | import hoist from '@/markdown/hoist.js' 3 | import { dataReturnable } from '@/markdown/index.js' 4 | 5 | const md = Md().set({ html: true }) 6 | const mdH = Md().set({ html: true }).use(hoist) 7 | 8 | dataReturnable(mdH) 9 | 10 | describe('hoist', () => { 11 | test('Should keep script and style when not using hoist', async () => { 12 | const input = await getFragment('hoist') 13 | const output = md.render(input) 14 | expect(output).toMatchSnapshot() 15 | }) 16 | 17 | test('Should miss script and style when using hoist', async () => { 18 | const input = await getFragment('hoist') 19 | const { html, data } = mdH.render(input) 20 | expect(html).toMatchSnapshot() 21 | expect(data).toMatchSnapshot() 22 | }) 23 | }) 24 | -------------------------------------------------------------------------------- /docs/assets/js/53.49d814c3.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[53],{161:function(t,a,e){"use strict";e.r(a);var s=e(0),r=Object(s.a)({},function(){this.$createElement;this._self._c;return this._m(0)},[function(){var t=this,a=t.$createElement,e=t._self._c||a;return e("div",{staticClass:"content"},[e("h1",{attrs:{id:"react组件"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#react组件","aria-hidden":"true"}},[t._v("#")]),t._v(" React组件")]),t._v(" "),e("h5",{attrs:{id:"无状态组件-视图组件"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#无状态组件-视图组件","aria-hidden":"true"}},[t._v("#")]),t._v(" 无状态组件(视图组件)")]),t._v(" "),e("h5",{attrs:{id:"class-继承-(容器组件)"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#class-继承-(容器组件)","aria-hidden":"true"}},[t._v("#")]),t._v(" class 继承 (容器组件)")])])}],!1,null,null,null);a.default=r.exports}}]); -------------------------------------------------------------------------------- /test/markdown/__snapshots__/lineNumers.spec.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`lineNumbers should lineNumbers work with highlightLines 1`] = ` 4 | 5 |
6 | 7 |
8 |
 
9 |
10 |
new Vue() 11 |
12 | 13 |
14 | 15 | `; 16 | 17 | exports[`lineNumbers should render lineNumbers 1`] = ` 18 | 19 |
20 |
new Vue()
21 | 
22 |
23 | 24 |
25 | 26 | `; 27 | -------------------------------------------------------------------------------- /test/markdown/slugify.spec.js: -------------------------------------------------------------------------------- 1 | import { Md } from './util' 2 | import anchor from 'markdown-it-anchor' 3 | import slugify from '@/markdown/slugify.js' 4 | 5 | const mdS = Md().use(anchor, { 6 | slugify, 7 | permalink: true, 8 | permalinkBefore: true, 9 | permalinkSymbol: '#' 10 | }) 11 | 12 | const asserts = { 13 | /* header: slug */ 14 | '# a b': 'a-b', 15 | '# a-b': 'a-b', 16 | '# ``': 'a', 17 | '# ``b': 'a-b', 18 | '# `` b': 'a-b' 19 | } 20 | 21 | describe('slugify', () => { 22 | test('should convert headers to slug correctly', () => { 23 | for (const input in asserts) { 24 | const output = mdS.render(input) 25 | expect(getSlug(output)).toBe(asserts[input]) 26 | } 27 | }) 28 | }) 29 | 30 | function getSlug (output) { 31 | return output.match(/id=\\?"([^"]*)\\?"/)[1] 32 | } 33 | -------------------------------------------------------------------------------- /test/markdown/__snapshots__/snippet.spec.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`snippet import snippet 1`] = ` 4 |
export default function () {
 5 |   // ..
 6 | }
 7 | 
8 | `; 9 | 10 | exports[`snippet import snippet with highlight multiple lines 1`] = ` 11 |
12 |
 
13 |
 
14 |
 
15 |
16 |
export default function () { // .. } 17 | `; 18 | 19 | exports[`snippet import snippet with highlight single line 1`] = ` 20 |
21 |
 
22 |
23 |
 
24 |
25 |
export default function () { // .. } 26 | `; 27 | -------------------------------------------------------------------------------- /test/default-theme/__snapshots__/NavLink.spec.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`NavLink $i18n - renders nav link with external link 1`] = ` 4 |
5 | Vue 6 | 7 | 8 | `; 9 | 10 | exports[`NavLink $i18n - renders nav link with internal link 1`] = `VuePress`; 11 | 12 | exports[`NavLink $simple - renders nav link with external link 1`] = ` 13 | 14 | Vue 15 | 16 | 17 | `; 18 | 19 | exports[`NavLink $simple - renders nav link with internal link 1`] = `VuePress`; 20 | -------------------------------------------------------------------------------- /lib/markdown/slugify.js: -------------------------------------------------------------------------------- 1 | // string.js slugify drops non ascii chars so we have to 2 | // use a custom implementation here 3 | const removeDiacritics = require('diacritics').remove 4 | // eslint-disable-next-line no-control-regex 5 | const rControl = /[\u0000-\u001f]/g 6 | const rSpecial = /[\s~`!@#$%^&*()\-_+=[\]{}|\\;:"'<>,.?/]+/g 7 | 8 | module.exports = function slugify (str) { 9 | return removeDiacritics(str) 10 | // Remove control characters 11 | .replace(rControl, '') 12 | // Replace special characters 13 | .replace(rSpecial, '-') 14 | // Remove continous separators 15 | .replace(/\-{2,}/g, '-') 16 | // Remove prefixing and trailing separtors 17 | .replace(/^\-+|\-+$/g, '') 18 | // ensure it doesn't start with a number (#121) 19 | .replace(/^(\d)/, '_$1') 20 | // lowercase 21 | .toLowerCase() 22 | } 23 | -------------------------------------------------------------------------------- /src/zh/vue/Promise.md: -------------------------------------------------------------------------------- 1 | # Promise/Aysnc 2 | #### 1、es6定义变量 3 | 1. var 4 | 2. let 5 | 3. import 6 | 4. class 7 | 5. function 8 | 6. const 9 | 10 | #### 2、Promise 11 | - 是异步编程的一种解决方案 12 | - 是一个对象 13 | 14 | **缺点** 15 | 1. 无法取消 16 | 17 | ``` 18 | Promise.all() 会包装多个实例成为一个新的promise实例 19 | 20 | new Promise((resolve.reject) =>{ 21 | // do some async function 22 | if(true){ 23 | // resolve 代表成功的回调 24 | resolve(data); 25 | }else{ 26 | // reject 代表失败的回调 27 | reject(data); 28 | } 29 | }) 30 | ``` 31 | #### 3、异步加载图片 32 | 1. 数据请求 -> 接口(Interface) 33 | 2. 创建图片 34 | 3. 插入到页面当中 35 | #### 4、继承 36 | obj1 extends obj2 37 | 38 | 如果继承就一定要在contructor第一行加super()方法 39 | #### 5、异步加载 40 | 1. ajax 41 | 2. 加载图片 42 | 3. jsonp 43 | 44 | #### 6、语法糖 45 | 再不改变代码的情况下让代码更简洁 46 | #### 7、async 47 | 1. 内置执行器 48 | 2. 更好的语义 49 | 3. 更广的适用性 50 | 4. 返回Promise -------------------------------------------------------------------------------- /test/default-theme/DropdownLink.spec.js: -------------------------------------------------------------------------------- 1 | import { mount, RouterLinkStub } from '@vue/test-utils' 2 | import DropdownLink from '@/default-theme/DropdownLink.vue' 3 | import { modeTestRunner } from '../util' 4 | 5 | function test (mode, localVue) { 6 | it(`$${mode} - renders dropdown link.`, () => { 7 | const item = { 8 | text: 'VuePress', 9 | items: [ 10 | { 11 | text: 'Guide', 12 | link: '/guide/' 13 | }, 14 | { 15 | text: 'Config Reference', 16 | link: '/config/' 17 | } 18 | ] 19 | } 20 | const wrapper = mount(DropdownLink, { 21 | localVue, 22 | stubs: { 23 | 'router-link': RouterLinkStub 24 | }, 25 | propsData: { item } 26 | }) 27 | expect(wrapper.html()).toMatchSnapshot() 28 | }) 29 | } 30 | 31 | modeTestRunner('DropdownLink', test) 32 | -------------------------------------------------------------------------------- /lib/app/index.ssr.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {{ title }} 7 | 8 | {{{ userHeadTags }}} 9 | {{{ pageMeta }}} 10 | {{{ renderResourceHints() }}} 11 | {{{ renderStyles() }}} 12 | 13 | 14 | 15 | {{{ renderScripts() }}} 16 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /test/markdown/__snapshots__/containers.spec.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`containers danger 1`] = ` 4 |
5 |

WARNING

6 |

I am a danger

7 |
8 | `; 9 | 10 | exports[`containers tip 1`] = ` 11 |
12 |

TIP

13 |

I am a tip

14 |
15 | `; 16 | 17 | exports[`containers tip-override 1`] = ` 18 |
19 |

提示

20 |

I am a tip

21 |
22 | `; 23 | 24 | exports[`containers v-pre 1`] = ` 25 |
26 |

I am a v-pre

27 |
28 | `; 29 | 30 | exports[`containers warning 1`] = ` 31 |
32 |

WARNING

33 |

I am a warning

34 |
35 | `; 36 | -------------------------------------------------------------------------------- /docs/assets/js/8.928a4419.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[8],{210:function(t,e,s){"use strict";s.r(e);var i=s(0),a=Object(i.a)({},function(){var t=this,e=t.$createElement,s=t._self._c||e;return s("div",{staticClass:"content"},[s("h2",{attrs:{id:""}},[s("a",{staticClass:"header-anchor",attrs:{href:"#","aria-hidden":"true"}},[t._v("#")]),t._v(" "),s("div",{staticStyle:{"text-align":"center"}},[s("Bit")],1)]),t._v(" "),s("div",[s("center",[s("h4",[t._v("努力不是为了取悦别人 而是照亮自己的心 告诉自己有一股独立向上的力量.")])])],1),t._v(" "),s("div",[s("center",[s("h4",[t._v("努力不是为了取悦别人 而是照亮自己的心 告诉自己有一股独立向上的力量.")])])],1),t._v(" "),s("hr"),t._v(" "),t._m(0)])},[function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"warning custom-block"},[e("p",{staticClass:"custom-block-title"},[this._v("兼容性注意事项")]),this._v(" "),e("p",[this._v("VuePress 要求 Node.js >= 8。")])])}],!1,null,null,null);e.default=a.exports}}]); -------------------------------------------------------------------------------- /test/app/Content.spec.js: -------------------------------------------------------------------------------- 1 | import Content from '@/app/components/Content' 2 | import { mount } from '@vue/test-utils' 3 | import { getRouter, modeTestRunner } from '../util' 4 | 5 | function test (mode, localVue) { 6 | it(`${mode} - add custom class by default.`, () => { 7 | const wrapper = mount(Content, { 8 | localVue, 9 | router: getRouter() 10 | }) 11 | expect(wrapper.contains('.custom')).toBe(true) 12 | }) 13 | 14 | it(`${mode} - remove custom when custom set to false.`, () => { 15 | const wrapper = mount(Content, { 16 | // https://vue-test-utils.vuejs.org/api/options.html#context 17 | context: { 18 | props: { 19 | custom: false 20 | } 21 | }, 22 | localVue, 23 | router: getRouter() 24 | }) 25 | expect(wrapper.contains('.custom')).toBe(false) 26 | }) 27 | } 28 | 29 | modeTestRunner('Content', test) 30 | 31 | -------------------------------------------------------------------------------- /lib/default-theme/styles/mobile.styl: -------------------------------------------------------------------------------- 1 | @require './config' 2 | 3 | $mobileSidebarWidth = $sidebarWidth * 0.82 4 | 5 | // narrow desktop / iPad 6 | @media (max-width: $MQNarrow) 7 | .sidebar 8 | font-size 15px 9 | width $mobileSidebarWidth 10 | .page 11 | padding-left $mobileSidebarWidth 12 | 13 | // wide mobile 14 | @media (max-width: $MQMobile) 15 | .sidebar 16 | top 0 17 | padding-top $navbarHeight 18 | transform translateX(-100%) 19 | transition transform .2s ease 20 | .page 21 | padding-left 0 22 | .theme-container 23 | &.sidebar-open 24 | .sidebar 25 | transform translateX(0) 26 | &.no-navbar 27 | .sidebar 28 | padding-top: 0 29 | 30 | // narrow mobile 31 | @media (max-width: $MQMobileNarrow) 32 | h1 33 | font-size 1.9rem 34 | .content 35 | div[class*="language-"] 36 | margin 0.85rem -1.5rem 37 | border-radius 0 38 | -------------------------------------------------------------------------------- /test/prepare/util.spec.js: -------------------------------------------------------------------------------- 1 | import { 2 | isIndexFile, 3 | fileToPath 4 | } from '@/prepare/util.js' 5 | 6 | describe('prepare - util', () => { 7 | test('isIndexFile', () => { 8 | [ 9 | 'README.md', 10 | 'readme.md', 11 | 'INDEX.md', 12 | 'index.md', 13 | 'foo/README.md', 14 | 'foo/index.md' 15 | ].forEach(file => { 16 | expect(isIndexFile(file)).toBe(true) 17 | }); 18 | [ 19 | 'foo/one.md', 20 | 'one.md' 21 | ].forEach(file => { 22 | expect(isIndexFile(file)).toBe(false) 23 | }) 24 | }) 25 | 26 | test('fileToPath', () => { 27 | const asserts = { 28 | 'README.md': '/', 29 | 'foo/README.md': '/foo/', 30 | 'foo.md': '/foo.html', 31 | 'foo/bar.md': '/foo/bar.html' 32 | } 33 | Object.keys(asserts).forEach(file => { 34 | expect(fileToPath(file)).toBe(asserts[file]) 35 | }) 36 | }) 37 | }) 38 | -------------------------------------------------------------------------------- /src/zh/miniapp/小程序组件.md: -------------------------------------------------------------------------------- 1 | # 小程序组件 2 | ##### 什么是组件 3 | > 组件就是将一个功能进行封装,组件是视图层的基本组成单元,有自己独特的功能 4 | ##### 组件的规范 5 | 1. 结构 6 | 1. 样式 7 | 1. 逻辑 8 | 1. 通信方式 9 | 1. 生命周期 10 | 1. 可组合(可以嵌套) 11 | 1. 定义组件 12 | 1. 调用组件(标签的形式) 13 | ##### 组件的创建 14 | 15 | ``` 16 | 1.小程序中组件由4个文件组成,.json .wxmll .wxss .js 17 | 2.创建组件实例需要通过Compoent(Object) 函数创建 18 | 3.创建组件需要在组件的json文件中定义 component:true 字段指定为一个组件 19 | 4.组件中的基础选项 20 | (1)Properties: 接受的数据 21 | (2)Data: 内部数据 22 | (3)Methods: 处理函数 23 | 5.使用组件 24 | 6.需要在对应的页面或者组件的json文件中定义 usingComponents: {} 选项 25 | usingComponets: { 26 | '名-称': '组件路径' 27 | } 28 | 7.在页面中可以实用 <名-称/> 29 | 8.名称中不能出现大写字母,规则就是(字母_-) 30 | 9.组件的组合可以实用slot插槽来完成,和vue一样,只不过没有作用域插槽, 可以有命名插槽和默认插槽 31 | 10.组件的通信可以通过props传递参数(父子), 自定义事件(子父) 32 | (1)父子 33 | (2)子父 组件内部通过this.triggerEvent(‘test’, {detail:对象}) 34 | ``` 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /lib/markdown/lineNumbers.js: -------------------------------------------------------------------------------- 1 | // markdown-it plugin for generating line numbers. 2 | // It depends on preWrapper plugin. 3 | 4 | module.exports = md => { 5 | const fence = md.renderer.rules.fence 6 | md.renderer.rules.fence = (...args) => { 7 | const rawCode = fence(...args) 8 | const code = rawCode.slice( 9 | rawCode.indexOf(''), 10 | rawCode.indexOf('') 11 | ) 12 | 13 | const lines = code.split('\n') 14 | const lineNumbersCode = [...Array(lines.length - 1)] 15 | .map((line, index) => `${index + 1}
`).join('') 16 | 17 | const lineNumbersWrapperCode = 18 | `
${lineNumbersCode}
` 19 | 20 | const finalCode = rawCode 21 | .replace('', `${lineNumbersWrapperCode}`) 22 | .replace('extra-class', 'line-numbers-mode') 23 | 24 | return finalCode 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/zh/interview/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 面试必备知识点 3 | sidebar: auto 4 | sidebarDepth: 2 5 | --- 6 | # 面试必备知识点 7 | 8 | ## CSS 9 | - 盒模型 10 | - CSS的单位和应用场景及Rem的设置 11 | - 定位,回流与重绘 12 | - IFC、BFC与清除浮动 13 | - 兼容处理 14 | 15 | ## 原生JS 16 | - 变量提升配合作用域链 17 | - 原型链 18 | - 继承 19 | - 闭包 20 | - new与面向对象 21 | - event loop 22 | - event delegation/proxy 23 | - 节流与防动 24 | - Promise原理 25 | - SPA路由原理 26 | - 本地存储localStorage、sessionStorage与cookie之间的区别 27 | 28 | ## Vue 29 | - 深入Vue的响应原理? 30 | - Vue多版本之间的区别(运行时依赖,运行时编译)? 31 | - Vue中computed、watch与methods的区别 32 | - 多种指令与自定义指令 33 | - 路由传参与导航守卫 34 | - Element UI && so on 35 | 36 | ## React 37 | - 什么是MVVM?React与Vue的区别与联系? 38 | - JSX语法、Virtual DOM与DOM Diff算法? 39 | - 详细介绍生命周期(三个阶段,生命周期的触发顺序)? 40 | - 合成事件与改变this指向的三种方式及之间的区别? 41 | - 样式绑定与CSS Modules 42 | - 多种组件创建方式及其区别?什么是受控组件? 43 | - 高阶组件与装饰器 44 | - 组件通信的多种方式及其之间的区别 45 | - React Router及其简单实现 46 | - Redux数据流向及三个中间件(redux-logger、redux-thunk、redux-saga) 47 | - Ant Design && so on -------------------------------------------------------------------------------- /lib/markdown/containers.js: -------------------------------------------------------------------------------- 1 | const container = require('markdown-it-container') 2 | 3 | module.exports = md => { 4 | md 5 | .use(...createContainer('tip', 'TIP')) 6 | .use(...createContainer('warning', 'WARNING')) 7 | .use(...createContainer('danger', 'WARNING')) 8 | // explicitly escape Vue syntax 9 | .use(container, 'v-pre', { 10 | render: (tokens, idx) => tokens[idx].nesting === 1 11 | ? `
\n` 12 | : `
\n` 13 | }) 14 | } 15 | 16 | function createContainer (klass, defaultTitle) { 17 | return [container, klass, { 18 | render (tokens, idx) { 19 | const token = tokens[idx] 20 | const info = token.info.trim().slice(klass.length).trim() 21 | if (token.nesting === 1) { 22 | return `

${info || defaultTitle}

\n` 23 | } else { 24 | return `
\n` 25 | } 26 | } 27 | }] 28 | } 29 | -------------------------------------------------------------------------------- /test/markdown/highlightLines.spec.js: -------------------------------------------------------------------------------- 1 | import { Md, getFragment } from './util' 2 | import highlightLines from '@/markdown/highlightLines.js' 3 | 4 | const md = Md() 5 | const mdH = Md().use(highlightLines) 6 | 7 | describe('highlightLines', () => { 8 | test('should the output not change when highlightLines is not detected', async () => { 9 | const input = await getFragment('code') 10 | const output1 = md.render(input) 11 | const output2 = mdH.render(input) 12 | expect(output1).toBe(output2) 13 | }) 14 | 15 | test('highlight single line', async () => { 16 | const input = await getFragment('code-highlightLines-single') 17 | const output = mdH.render(input) 18 | expect(output).toMatchSnapshot() 19 | }) 20 | 21 | test('highlight multiple lines', async () => { 22 | const input = await getFragment('code-highlightLines-multiple') 23 | const output = mdH.render(input) 24 | expect(output).toMatchSnapshot() 25 | }) 26 | }) 27 | -------------------------------------------------------------------------------- /test/default-theme/NavLink.spec.js: -------------------------------------------------------------------------------- 1 | import { mount, RouterLinkStub } from '@vue/test-utils' 2 | import { modeTestRunner } from '../util' 3 | import NavLink from '@/default-theme/NavLink.vue' 4 | 5 | function test (mode, localVue) { 6 | it(`$${mode} - renders nav link with internal link`, () => { 7 | const item = { 8 | link: '/', 9 | text: 'VuePress' 10 | } 11 | const wrapper = mount(NavLink, { 12 | localVue, 13 | stubs: { 14 | 'router-link': RouterLinkStub 15 | }, 16 | propsData: { item } 17 | }) 18 | expect(wrapper.html()).toMatchSnapshot() 19 | }) 20 | 21 | it(`$${mode} - renders nav link with external link`, () => { 22 | const item = { 23 | link: 'http://vuejs.org/', 24 | text: 'Vue' 25 | } 26 | const wrapper = mount(NavLink, { 27 | localVue, 28 | propsData: { item } 29 | }) 30 | expect(wrapper.html()).toMatchSnapshot() 31 | }) 32 | } 33 | 34 | modeTestRunner('NavLink', test) 35 | -------------------------------------------------------------------------------- /test/markdown/lineNumers.spec.js: -------------------------------------------------------------------------------- 1 | import { Md, getFragment } from './util' 2 | import preWrapper from '@/markdown/preWrapper.js' 3 | import lineNumbers from '@/markdown/lineNumbers.js' 4 | import highlightLines from '@/markdown/highlightLines.js' 5 | 6 | // lineNumbers must be chained after preWrapper. 7 | // since lineNumbers needs to add extra stateful class to its block wrapper. 8 | const mdL = Md().use(preWrapper).use(lineNumbers) 9 | const mdLH = Md().use(highlightLines).use(preWrapper).use(lineNumbers) 10 | 11 | describe('lineNumbers', () => { 12 | test('should render lineNumbers', async () => { 13 | const input = await getFragment('code') 14 | const output = mdL.render(input) 15 | expect(output).toMatchSnapshot() 16 | }) 17 | 18 | test('should lineNumbers work with highlightLines', async () => { 19 | const input = await getFragment('code-highlightLines-single') 20 | const output = mdLH.render(input) 21 | expect(output).toMatchSnapshot() 22 | }) 23 | }) 24 | -------------------------------------------------------------------------------- /src/zh/miniapp/小程序组件化.md: -------------------------------------------------------------------------------- 1 | # 小程序组件化 2 | ##### wxml节点信息API 3 | - 在小程序中使用**wx.createSelectorQuery()**获取到**SelectorQuery**对象,这个对象提供了对应的节点操作方法 4 | - **in(this)** 将节点选区范围指向当前组件,默认只会查找当期页面 5 | - **select()** 根据css选择器查询到匹配结果的第一个元素节点,返回的 NodesRef对象实例 6 | - **selectAll()** 和select一样只不过他可以匹配多个 7 | - **selectViewport()** 选择显示区域(页面),可用于获取显示区域的尺寸、滚动位置等信息,返回一个NodesRef对象实例。 8 | - **exec()** 执行所有的请求,请求结果按请求次序构成数组,在callback的第一个参数中返回。 9 | ##### NodesRef对象 10 | 1、 **boundingClientRect([callback])** 11 | > 获取节点信息, 返回值相对于显示区域,以像素为单位。 12 | 返回节点的信息有**left、right、top、bottom、width、height** 如果提供了callback回调函数,在执行selectQuery的exec方法后,节点信息会在callback中返回 13 | 14 | 2、**scrollOffset([callback])** 15 | > 获取滚动位置信息,只针对与scroll-view组件以及viewport页面起作用,返回值是**scrollLeft、scrollTop**,如果提供了callback回调函数,在执行selectQuery的exec方法后,节点信息会在callback中返回 16 | 17 | 3、**fields(Object, [callback])** 18 | > 指定获取那些信息 (id, dataset, rect, size, scrollOffset , properties=[获取的常规属性名称(注:id class style 除外)], computedStyle=[获取的样式名称]) 19 | 20 | -------------------------------------------------------------------------------- /test/markdown/snippet.spec.js: -------------------------------------------------------------------------------- 1 | import { Md, getFragment } from './util' 2 | import snippet from '@/markdown/snippet.js' 3 | import highlightLines from '@/markdown/highlightLines.js' 4 | 5 | const md = Md().use(snippet) 6 | const mdH = Md().use(snippet).use(highlightLines) 7 | 8 | describe('snippet', () => { 9 | test('import snippet', async () => { 10 | const input = await getFragment('code-snippet') 11 | const output = md.render(input) 12 | expect(output).toMatchSnapshot() 13 | }) 14 | 15 | test('import snippet with highlight single line', async () => { 16 | const input = await getFragment('code-snippet-highlightLines-single') 17 | const output = mdH.render(input) 18 | expect(output).toMatchSnapshot() 19 | }) 20 | 21 | test('import snippet with highlight multiple lines', async () => { 22 | const input = await getFragment('code-snippet-highlightLines-multiple') 23 | const output = mdH.render(input) 24 | expect(output).toMatchSnapshot() 25 | }) 26 | }) 27 | -------------------------------------------------------------------------------- /src/zh/vue/vue钩子函数.md: -------------------------------------------------------------------------------- 1 | # Vue钩子 2 | #### 1、钩子函数 3 | 指令定义函数提供了几个钩子函数(可选): 4 | 5 | - bind: 只调用一次,指令第一次绑定到元素时调用,用这个钩子函数可以定义一个在绑定时执行一次的初始化动作。 6 | 7 | - inserted: 被绑定元素插入父节点时调用(父节点存在即可调用,不必存在于 document 中)。 8 | 9 | - update: 被绑定元素所在的模板更新时调用,而不论绑定值是否变化。通过比较更新前后的绑定值,可以忽略不必要的模板更新(详细的钩子函数参数见下)。 10 | 11 | - componentUpdated: 被绑定元素所在模板完成一次更新周期时调用。 12 | 13 | - unbind: 只调用一次, 指令与元素解绑时调用。 14 | #### 2、钩子函数参数 15 | 钩子函数的参数有: 16 | 17 | 1. el: 指令所绑定的元素,可以用来直接操作 DOM 。 18 | 2. binding: 一个对象,包含以下属性: 19 | 20 | ``` 21 | name: 指令名,不包括 v- 前缀 22 | value: 指令的绑定值, 例如: v-my-directive="1 + 1", value 的值是 2。 23 | oldValue: 指令绑定的前一个值,仅在 update 和 componentUpdated 钩子中可用。无论值是否改变都可用。 24 | expression: 绑定值的表达式或变量名。 例如 v-my-directive="1 + 1" , expression 的值是 "1 + 1"。 25 | arg: 传给指令的参数。例如 v-my-directive:foo, arg 的值是 "foo"。 26 | modifiers: 一个包含修饰符的对象。 例如: v-my-directive.foo.bar, 修饰符对象 modifiers 的值是 { foo: true, bar: true }。 27 | ``` 28 | 29 | 3. vnode: Vue 编译生成的虚拟节点。 30 | 4. oldVnode: 上一个虚拟节点,仅在 update 和 componentUpdated 钩子中可用。 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/zh/vue/Vue路由.md: -------------------------------------------------------------------------------- 1 | # Vue路由 2 | #### 1、路由(外置的) vue-router 3 | 4 | ``` 5 | import VueRouter from 'vue-router'; 6 | import Index from './components/index.vue'; 7 | import List from './components/index.vue'; 8 | import Login from './components/index.vue'; 9 | 10 | Vue.use(VueRouter); // 注册 11 | let router = new VueRouter({ 12 | routes:[{ // 定义多个路由 13 | path:'/index', 14 | component:Index 15 | },{ 16 | path:'/list', 17 | component:List 18 | },{ 19 | path:'/login', 20 | component:Login 21 | },{ 22 | path:'/music', 23 | component:Music, 24 | children:[{ // 封装子路由 25 | path:'/comd', 26 | component:Comd 27 | },{ 28 | path:'/search', 29 | component:Search 30 | }] 31 | }] 32 | }) 33 | 34 | 35 | app.vue // 入口文件 36 | 37 | ``` 38 | #### 2、路由跳转路径 39 | 40 | ``` 41 | 推荐 42 | 43 | router-link === a 44 | to === href 45 | ``` 46 | 47 | 48 | -------------------------------------------------------------------------------- /docs/assets/js/48.9e2f6119.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[48],{166:function(t,a,e){"use strict";e.r(a);var s=e(0),i=Object(s.a)({},function(){this.$createElement;this._self._c;return this._m(0)},[function(){var t=this,a=t.$createElement,e=t._self._c||a;return e("div",{staticClass:"content"},[e("h1",{attrs:{id:"jsx"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#jsx","aria-hidden":"true"}},[t._v("#")]),t._v(" JSX")]),t._v(" "),e("h4",{attrs:{id:"_1、jsx是什么"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#_1、jsx是什么","aria-hidden":"true"}},[t._v("#")]),t._v(" 1、jsx是什么?")]),t._v(" "),e("ul",[e("li",[t._v("React 使用 JSX 来替代常规的 JavaScript")]),t._v(" "),e("li",[t._v("JSX 是一个看起来很像 XML 的 JavaScript 语法扩展")]),t._v(" "),e("li",[t._v("我们不需要一定使用 JSX,但它有以下优点")])]),t._v(" "),e("ol",[e("li",[e("blockquote",[e("p",[t._v("JSX 执行更快,因为它在编译为 JavaScript 代码后进行了优化")])])]),t._v(" "),e("li",[e("blockquote",[e("p",[t._v("它是类型安全的,在编译过程中就能发现错误")])])]),t._v(" "),e("li",[e("blockquote",[e("p",[t._v("使用 JSX 编写模板更加简单快速")])])])])])}],!1,null,null,null);a.default=i.exports}}]); -------------------------------------------------------------------------------- /lib/util/logger.js: -------------------------------------------------------------------------------- 1 | const chalk = require('chalk') 2 | 3 | const logger = {} 4 | 5 | const logTypes = { 6 | success: { 7 | color: 'green', 8 | label: 'DONE' 9 | }, 10 | error: { 11 | color: 'red', 12 | label: 'FAIL' 13 | }, 14 | warn: { 15 | color: 'yellow', 16 | label: 'WARN' 17 | }, 18 | tip: { 19 | color: 'cyan', 20 | label: 'TIP' 21 | }, 22 | wait: { 23 | color: 'blue', 24 | label: 'WAIT' 25 | } 26 | } 27 | 28 | const getLoggerFn = (color, label) => (msg, log = true) => { 29 | let newLine = false 30 | if (msg.startsWith('\n')) { 31 | if (log) msg = msg.slice(1) 32 | newLine = true 33 | } 34 | msg = chalk.reset.inverse.bold[color](` ${label} `) + ' ' + msg 35 | if (log) { 36 | console.log(newLine ? '\n' + msg : msg) 37 | } else { 38 | return msg 39 | } 40 | } 41 | 42 | for (const type in logTypes) { 43 | const { color, label } = logTypes[type] 44 | logger[type] = getLoggerFn(color, label) 45 | } 46 | 47 | module.exports = logger 48 | module.exports.getLoggerFn = getLoggerFn 49 | -------------------------------------------------------------------------------- /src/zh/interface/TouTiao.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 今日头条小程序接口 3 | sidebar: auto 4 | sidebarDepth: 2 5 | --- 6 | # 今日头条小程序的接口 7 | 8 | ## 首页 9 | ### 获取顶部tab 10 | - url: get https://m.toutiao.com/pwa/api/wxapp/settings 11 | 12 | ### 分类tab切换 13 | - url: get https://lf.snssdk.com/api/news/feed/v66/?language=zh-Hans-CN&count=20&category=[tab分类]&aid=1162&min_behot_time=[分页behot_time]&device_id=6650307045722932750 14 | 15 | ### 获取资讯详情 16 | - url: get https://m.toutiao.com/pwa/api/wxapp/info/[资讯的id]/ 17 | 18 | ### 获取资讯评论 19 | - url: get https://ib.snssdk.com/article/v1/tab_comments/?group_id=[资讯的id]&&tab_index=0&count=[分页数量]&offset=[分页偏移] 20 | 21 | ### 生成小程序码 22 | - url: get https://m.toutiao.com/pwa/api/wxapp/wxacode/?id=[资讯的id]&group_id=[资讯的id]&channel=0&page=pages/detail/detail 23 | 24 | ### 搜索提示接口 25 | - url: get https://lf.snssdk.com/2/article/search_sug/?keyword=[搜索关键字]&device_id=6650307045722932750 26 | 27 | ### 搜索结果接口 28 | - url: get https://lf.snssdk.com/api/2/wap/search_content/?keyword=[搜索关键字]&count=10&format=json&offset=[分页偏移]&search_text=[搜索提示结果]&device_id=6650307045722932750 -------------------------------------------------------------------------------- /lib/default-theme/SidebarButton.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 29 | -------------------------------------------------------------------------------- /lib/app/components/Badge.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 47 | -------------------------------------------------------------------------------- /lib/default-theme/NavLink.vue: -------------------------------------------------------------------------------- 1 | 19 | 20 | 50 | -------------------------------------------------------------------------------- /src/zh/react/redux中间件.md: -------------------------------------------------------------------------------- 1 | # Redux中间件 2 | ##### 1、applyMiddleware 3 | - 方便调试,实时触发,线下使用 4 | 5 | ``` 6 | import {createStore,applyMiddleware} from 'redux'; 7 | import reducers from './reducers'; 8 | import Logger from 'redux-logger'; 9 | 10 | export default createStore(reducers, applyMiddleware(Logger)) 11 | ``` 12 | ##### 2、redux-thunk 13 | - 目的:异步解决方案 14 | - 支持action的写法有对象变为函数 15 | - 可以发送多个dispatch 16 | - 改变action 17 | - 同时会帮我们注入两个参数dispatch和getState 18 | - 在异步操作完成之后再触发dispatch操作 19 | ``` 20 | dispatch((dispatch, getState)=>{ 21 | // getState可以获取全局的state 22 | dispatch({ 23 | type:"START" 24 | }) 25 | fetch('/data.json') 26 | .then(res=>res.json()) 27 | .then(success=>{ 28 | if(success){ 29 | dispatch({ 30 | type:"FETCH_LIST", 31 | payLoad:success.arr 32 | }) 33 | }else{ 34 | dispatch({ 35 | type:"FETCH_TAIL" 36 | }) 37 | } 38 | }) 39 | }) 40 | ``` 41 | ##### 3、redux-saga 42 | - 拦截请求 43 | - 解决异步 44 | - 不会改变action 45 | - take 拦截 46 | - takeEvery 每次都拦截 47 | ##### 4、redux-thunk 48 | - 改写action 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | logo 3 |

4 | 5 | ## Target 6 | 收集优质内容和经典问题 7 | 8 | 欢迎捐款! 9 | 10 | ## Edit Content 11 | ``` bash 12 | # 启动开发服务 13 | npm run dev 14 | 15 | # 添加导航 text&link 16 | modify /src/.vuepress/config.js 17 | such as: 18 | { 19 | text: '快速搭建开发环境', 20 | link: '/zh/standard/Start.md' 21 | } 22 | 23 | # 创建一个 markdown 文件 24 | touch /src/zh/standard/Start.md 25 | 26 | # 添加内容 27 | 28 | # 构建为静态文件 29 | npm run build 30 | 31 | # 提交代码到仓库 32 | ``` 33 | 34 | ## Development 35 | 36 | > 请确保您的Node.js版本大于8。 37 | 38 | ``` bash 39 | npm run dev #为自己提供VuePress自己的文档 40 | ``` 41 | 42 | ## Deploy 43 | ``` bash 44 | npm run build 45 | ``` 46 | 47 | 52 | 53 | ## License 54 | 55 | MIT 56 | 57 | -------------------------------------------------------------------------------- /test/default-theme/__snapshots__/DropdownLink.spec.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`DropdownLink $i18n - renders dropdown link. 1`] = ` 4 | 17 | `; 18 | 19 | exports[`DropdownLink $simple - renders dropdown link. 1`] = ` 20 | 33 | `; 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (https://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # TypeScript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | # next.js build output 61 | .next 62 | -------------------------------------------------------------------------------- /docs/assets/js/64.4b0c2825.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[64],{150:function(e,a,t){"use strict";t.r(a);var s=t(0),n=Object(s.a)({},function(){this.$createElement;this._self._c;return this._m(0)},[function(){var e=this,a=e.$createElement,t=e._self._c||a;return t("div",{staticClass:"content"},[t("h1",{attrs:{id:"babel"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#babel","aria-hidden":"true"}},[e._v("#")]),e._v(" Babel")]),e._v(" "),t("h4",{attrs:{id:"_1、babel"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#_1、babel","aria-hidden":"true"}},[e._v("#")]),e._v(" 1、Babel")]),e._v(" "),t("ul",[t("li",[e._v("是javascript的编译器/解码器/转码器/解析器")])]),e._v(" "),t("h4",{attrs:{id:"_2、配置"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#_2、配置","aria-hidden":"true"}},[e._v("#")]),e._v(" 2、配置")]),e._v(" "),t("ul",[t("li",[e._v(".babelrc")])]),e._v(" "),t("div",{staticClass:"language- extra-class"},[t("pre",{pre:!0,attrs:{class:"language-text"}},[t("code",[e._v('命令:\n babel ./index.js -o ./_index.js\n下包:\n cnpm install --save-dev babel-cli babel-preset-env\n \n \n{\n "presets": [\n "env"\n ]\n}\n\nbabel-loader // es6转es5\n')])])])])}],!1,null,null,null);a.default=n.exports}}]); -------------------------------------------------------------------------------- /lib/app/SWUpdateEvent.js: -------------------------------------------------------------------------------- 1 | export default class SWUpdateEvent { 2 | constructor (registration) { 3 | Object.defineProperty(this, 'registration', { 4 | value: registration, 5 | configurable: true, 6 | writable: true 7 | }) 8 | } 9 | 10 | /** 11 | * Check if the new service worker exists or not. 12 | */ 13 | update () { 14 | return this.registration.update() 15 | } 16 | 17 | /** 18 | * Activate new service worker to work 'location.reload()' with new data. 19 | */ 20 | skipWaiting () { 21 | const worker = this.registration.waiting 22 | if (!worker) { 23 | return Promise.resolve() 24 | } 25 | 26 | console.log('[vuepress:sw] Doing worker.skipWaiting().') 27 | return new Promise((resolve, reject) => { 28 | const channel = new MessageChannel() 29 | 30 | channel.port1.onmessage = (event) => { 31 | console.log('[vuepress:sw] Done worker.skipWaiting().') 32 | if (event.data.error) { 33 | reject(event.data.error) 34 | } else { 35 | resolve(event.data) 36 | } 37 | } 38 | 39 | worker.postMessage({ type: 'skip-waiting' }, [channel.port2]) 40 | }) 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /lib/default-theme/styles/nprogress.styl: -------------------------------------------------------------------------------- 1 | #nprogress 2 | pointer-events none 3 | .bar 4 | background $accentColor 5 | position fixed 6 | z-index 1031 7 | top 0 8 | left 0 9 | width 100% 10 | height 2px 11 | .peg 12 | display block 13 | position absolute 14 | right 0px 15 | width 100px 16 | height 100% 17 | box-shadow 0 0 10px $accentColor, 0 0 5px $accentColor 18 | opacity 1.0 19 | transform rotate(3deg) translate(0px, -4px) 20 | .spinner 21 | display block 22 | position fixed 23 | z-index 1031 24 | top 15px 25 | right 15px 26 | .spinner-icon 27 | width 18px 28 | height 18px 29 | box-sizing border-box 30 | border solid 2px transparent 31 | border-top-color $accentColor 32 | border-left-color $accentColor 33 | border-radius 50% 34 | animation nprogress-spinner 400ms linear infinite 35 | 36 | .nprogress-custom-parent 37 | overflow hidden 38 | position relative 39 | 40 | .nprogress-custom-parent #nprogress .spinner, 41 | .nprogress-custom-parent #nprogress .bar 42 | position absolute 43 | 44 | @keyframes nprogress-spinner 45 | 0% 46 | transform rotate(0deg) 47 | 100% 48 | transform rotate(360deg) 49 | -------------------------------------------------------------------------------- /src/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | home: true 3 | heroImage: /avatar.jpg 4 | actionText: Let`s Go → 5 | actionLink: /zh/standard/Start.html 6 | sidebarDepth: 2 7 | sidebar: auto 8 | footer: MIT Licensed | Copyright © 1970-present 1z2s 9 | --- 10 | 11 |
12 | 13 |
14 | --- 15 |
16 |

努力不是为了取悦别人 而是照亮自己的心 告诉自己有一股独立向上的力量.

17 | 18 |
19 |
20 |

努力不是为了取悦别人 而是照亮自己的心 告诉自己有一股独立向上的力量.

21 | 22 |
23 | 24 | 25 | 39 | 40 | 41 | 42 | 55 | --- 56 | 57 | 58 | :::warning 兼容性注意事项 59 | VuePress 要求 Node.js >= 8。 60 | ::: 61 | -------------------------------------------------------------------------------- /lib/webpack/DevLogPlugin.js: -------------------------------------------------------------------------------- 1 | const chalk = require('chalk') 2 | const logger = require('../util/logger') 3 | 4 | module.exports = class DevLogPlugin { 5 | constructor (options) { 6 | this.options = options 7 | } 8 | 9 | apply (compiler) { 10 | let isFirst = true 11 | compiler.hooks.done.tap('vuepress-log', stats => { 12 | clearScreen() 13 | 14 | const { displayHost, port, publicPath } = this.options 15 | const time = new Date().toTimeString().match(/^[\d:]+/)[0] 16 | const displayUrl = `http://${displayHost}:${port}${publicPath}` 17 | 18 | logger.success( 19 | `\n${chalk.gray(`[${time}]`)} Build ${chalk.italic(stats.hash.slice(0, 6))} ` + 20 | `finished in ${stats.endTime - stats.startTime} ms! ` + 21 | ( 22 | isFirst 23 | ? '' 24 | : `${chalk.gray(`(${displayUrl})`)}` 25 | ) 26 | ) 27 | if (isFirst) { 28 | isFirst = false 29 | console.log(`\n${chalk.gray('>')} VuePress dev server listening at ${chalk.cyan(displayUrl)}`) 30 | } 31 | }) 32 | compiler.hooks.invalid.tap('vuepress-log', clearScreen) 33 | } 34 | } 35 | 36 | function clearScreen () { 37 | process.stdout.write('\x1Bc') 38 | } 39 | -------------------------------------------------------------------------------- /test/util.js: -------------------------------------------------------------------------------- 1 | import { createLocalVue } from '@vue/test-utils' 2 | import dataMixin from '@/app/dataMixin' 3 | import Router from 'vue-router' 4 | import { mockComponent } from './hoc' 5 | import { siteData as i18nSiteData } from './.temp/siteData-i18n' 6 | import { siteData as simpleSiteData } from './.temp/siteData-simple' 7 | 8 | export function getRouter () { 9 | return new Router() 10 | } 11 | 12 | export function getLocalVueByMode (mode) { 13 | const localVue = createLocalVue() 14 | localVue.use(Router) 15 | 16 | // register global component 17 | localVue.component('OutboundLink', mockComponent('outbound-link')) 18 | 19 | // register page component in root route. 20 | localVue.component(i18nSiteData.pages[0].key, mockComponent('page-component')) 21 | localVue.component(simpleSiteData.pages[0].key, mockComponent('page-component')) 22 | 23 | // data mixin 24 | if (mode === 'i18n') { 25 | localVue.mixin(dataMixin(i18nSiteData)) 26 | } else { 27 | localVue.mixin(dataMixin(simpleSiteData)) 28 | } 29 | 30 | return localVue 31 | } 32 | 33 | export function modeTestRunner (description, testFn, modes = ['simple', 'i18n']) { 34 | if (!Array.isArray(modes)) { 35 | modes = [modes] 36 | } 37 | modes.forEach(mode => { 38 | describe(description, () => { 39 | testFn(mode, getLocalVueByMode(mode)) 40 | }) 41 | }) 42 | } 43 | -------------------------------------------------------------------------------- /src/zh/miniapp/WXS.md: -------------------------------------------------------------------------------- 1 | # WXS 2 | ##### wxs是什么? 3 | > WXS(WeiXin Script)是小程序的一套脚本语言,结合 WXML,可以构建出页面的结构。 4 | ##### 注意 5 | 1. wxs 不依赖于运行时的基础库版本,可以在所有版本的小程序中运行。 6 | 1. wxs 与 javascript 是不同的语言,有自己的语法,并不和 javascript 一致。 7 | 1. wxs 的运行环境和其他 javascript 代码是隔离的,wxs 中不能调用其他 javascript文件中定义的函数,也不能调用小程序提供的API。 8 | 1. wxs 函数不能作为组件的事件回调。 9 | 1. 由于运行环境的差异,在 iOS 设备上小程序内的 wxs 会比 javascript 代码快 2 ~ 20 倍。在 android 设备上二者运行效率无差异。 10 | 11 | 12 | ##### 页面渲染 13 | 14 | ``` 15 | 16 | 17 | var msg = "hello world"; 18 | 19 | module.exports.message = msg; 20 | 21 | 22 | {{m1.message}} 23 | 24 | 25 | 页面输出 26 | hello world 27 | ``` 28 | 29 | ##### 数据处理 30 | 31 | ``` 32 | // page.js 33 | Page({ 34 | data: { 35 | array: [1, 2, 3, 4, 5, 1, 2, 3, 4] 36 | } 37 | }) 38 | ``` 39 | 40 | ``` 41 | 42 | 43 | 44 | var getMax = function(array) { 45 | var max = undefined; 46 | for (var i = 0; i < array.length; ++i) { 47 | max = max === undefined ? 48 | array[i] : 49 | (max >= array[i] ? max : array[i]); 50 | } 51 | return max; 52 | } 53 | 54 | module.exports.getMax = getMax; 55 | 56 | 57 | 58 | {{m1.getMax(array)}} 59 | ``` 60 | 页面输出 61 | 62 | ``` 63 | 5 64 | ``` 65 | 66 | 67 | -------------------------------------------------------------------------------- /lib/markdown/highlight.js: -------------------------------------------------------------------------------- 1 | const chalk = require('chalk') 2 | const prism = require('prismjs') 3 | const loadLanguages = require('prismjs/components/index') 4 | const escapeHtml = require('escape-html') 5 | const logger = require('../util/logger') 6 | 7 | // required to make embedded highlighting work... 8 | loadLanguages(['markup', 'css', 'javascript']) 9 | 10 | function wrap (code, lang) { 11 | if (lang === 'text') { 12 | code = escapeHtml(code) 13 | } 14 | return `
${code}
` 15 | } 16 | 17 | module.exports = (str, lang) => { 18 | if (!lang) { 19 | return wrap(str, 'text') 20 | } 21 | lang = lang.toLowerCase() 22 | const rawLang = lang 23 | if (lang === 'vue' || lang === 'html') { 24 | lang = 'markup' 25 | } 26 | if (lang === 'md') { 27 | lang = 'markdown' 28 | } 29 | if (lang === 'ts') { 30 | lang = 'typescript' 31 | } 32 | if (lang === 'py') { 33 | lang = 'python' 34 | } 35 | if (!prism.languages[lang]) { 36 | try { 37 | loadLanguages([lang]) 38 | } catch (e) { 39 | logger.warn(chalk.yellow(`[vuepress] Syntax highlight for language "${lang}" is not supported.`)) 40 | } 41 | } 42 | if (prism.languages[lang]) { 43 | const code = prism.highlight(str, prism.languages[lang], lang) 44 | return wrap(code, rawLang) 45 | } 46 | return wrap(str, 'text') 47 | } 48 | -------------------------------------------------------------------------------- /src/guide/getting-started.md: -------------------------------------------------------------------------------- 1 | # 起步 2 | 3 | ::: warning 兼容性注意事项 4 | VuePress 要求 Node.js >= 8。 5 | ::: 6 | 7 | ## 全局安装 8 | 9 | 如果你只是想随便用下 VuePress,你可以在全局安装它: 10 | 11 | ``` bash 12 | # 全局安装 13 | yarn global add vuepress # 或 npm install -g vuepress 14 | 15 | # 创建一个 markdown 文件 16 | echo '# Hello VuePress' > README.md 17 | 18 | # 开始编写文档 19 | vuepress dev 20 | 21 | # 构建 22 | vuepress build 23 | ``` 24 | 25 | ## 在已有项目中安装 26 | 27 | 如果你想要在一个已有项目中维护文档,就应该将 VuePress 安装为本地依赖。此设置还允许你使用 CI 或 Netlify 服务,在推送时自动部署。 28 | 29 | ``` bash 30 | # 安装为本地依赖项 31 | yarn add -D vuepress # 或 npm install -D vuepress 32 | 33 | # 创建一个 docs 目录 34 | mkdir docs 35 | # 创建一个 markdown 文件 36 | echo '# Hello VuePress' > docs/README.md 37 | ``` 38 | 39 | ::: warning 警告 40 | 当将 VuePress 安装到以 webpack 3.x 作为依赖项的已有项目中时,推荐使用[Yarn](https://yarnpkg.com/en/) 而不是 npm。因为在这种情况下,Npm 无法生成正确的依赖关系树。 41 | ::: 42 | 43 | 然后,给 `package.json` 添加一些 scripts 脚本: 44 | 45 | ``` json 46 | { 47 | "scripts": { 48 | "docs:dev": "vuepress dev docs", 49 | "docs:build": "vuepress build docs" 50 | } 51 | } 52 | ``` 53 | 54 | 你现在就可以开始编写文档了: 55 | 56 | ``` bash 57 | yarn docs:dev # 或 npm run docs:dev 58 | ``` 59 | 60 | 要生成静态资源,请运行: 61 | 62 | ``` bash 63 | yarn docs:build # 或 npm run docs:build 64 | ``` 65 | 66 | 默认情况下,构建的文件会位于 `.vuepress/dist` 中,该文件可以通过 `.vuepress/config.js` 中的 `dest` 字段进行配置。构建的文件可以部署到任何静态文件服务器。关于如何部署到一些常用服务,请参考 [部署指南](./deploy.md)。 67 | -------------------------------------------------------------------------------- /scripts/release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Select a option to release (input a serial number):" 4 | echo 5 | 6 | select VERSION in patch minor major "Specific Version" 7 | do 8 | echo 9 | if [[ $REPLY =~ ^[1-4]$ ]]; then 10 | if [[ $REPLY == 4 ]]; then 11 | read -p "Enter a specific version: " -r VERSION 12 | echo 13 | if [[ -z $REPLY ]]; then 14 | VERSION=$REPLY 15 | fi 16 | fi 17 | 18 | read -p "Release $VERSION - are you sure? (y/n) " -n 1 -r 19 | echo 20 | 21 | if [[ $REPLY =~ ^[Yy]$ || -z $REPLY ]]; then 22 | # pre release task 23 | npm run lint 24 | npm run test 25 | 26 | # bump version 27 | npm version $VERSION 28 | NEW_VERSION=$(node -p "require('./package.json').version") 29 | echo Releasing ${NEW_VERSION} ... 30 | 31 | # npm release 32 | npm whoami 33 | npm publish 34 | echo "✅ Released to npm." 35 | 36 | # github release 37 | git add CHANGELOG.md 38 | git commit -m "chore: changelog" 39 | git push 40 | git push origin refs/tags/v${NEW_VERSION} 41 | echo "✅ Released to Github." 42 | else 43 | echo Cancelled 44 | fi 45 | break 46 | else 47 | echo Invalid \"${REPLY}\" 48 | echo "To continue, please input a serial number(1-4) of an option." 49 | echo 50 | fi 51 | done 52 | 53 | -------------------------------------------------------------------------------- /src/zh/guide/getting-started.md: -------------------------------------------------------------------------------- 1 | # 快速上手 2 | 3 | ::: warning 注意 4 | 请确保你的 Node.js 版本 >= 8。 5 | ::: 6 | 7 | ## 全局安装 8 | 9 | 如果你只是想尝试一下 VuePress,你可以全局安装它: 10 | 11 | ``` bash 12 | # 安装 13 | yarn global add vuepress # 或者:npm install -g vuepress 14 | 15 | # 新建一个 markdown 文件 16 | echo "# Hello VuePress!" > README.md 17 | 18 | # 开始写作 19 | vuepress dev . 20 | 21 | # 构建静态文件 22 | vuepress build . 23 | ``` 24 | 25 | ## 现有项目 26 | 27 | 如果你想在一个现有项目中使用 VuePress,同时想要在该项目中管理文档,则应该将 VuePress 安装为本地依赖。作为本地依赖安装让你可以使用持续集成工具,或者一些其他服务(比如 Netlify)来帮助你在每次提交代码时自动部署。 28 | 29 | ``` bash 30 | # 将 VuePress 作为一个本地依赖安装 31 | yarn add -D vuepress # 或者:npm install -D vuepress 32 | 33 | # 新建一个 study 文件夹 34 | mkdir study 35 | 36 | # 新建一个 markdown 文件 37 | echo "# Hello VuePress!" > study/README.md 38 | 39 | # 开始写作 40 | npx vuepress dev study 41 | ``` 42 | 43 | ::: warning 44 | 如果你的现有项目依赖了 webpack 3.x,推荐使用 [Yarn](https://yarnpkg.com/en/) 而不是 npm 来安装 VuePress。因为在这种情形下,npm 会生成错误的依赖树。 45 | ::: 46 | 47 | 接着,在 `package.json` 里加一些脚本: 48 | 49 | ``` json 50 | { 51 | "scripts": { 52 | "study:dev": "vuepress dev study", 53 | "study:build": "vuepress build study" 54 | } 55 | } 56 | ``` 57 | 58 | 然后就可以开始写作了: 59 | 60 | ``` bash 61 | yarn study:dev # 或者:npm run study:dev 62 | ``` 63 | 64 | 要生成静态的 HTML 文件,运行: 65 | 66 | ``` bash 67 | yarn study:build # 或者:npm run study:build 68 | ``` 69 | 70 | 默认情况下,文件将会被生成在 `.vuepress/dist`,当然,你也可以通过 `.vuepress/config.js` 中的 `dest` 字段来修改,生成的文件可以部署到任意的静态文件服务器上,参考 [部署](./deploy.md) 来了解更多。 71 | -------------------------------------------------------------------------------- /README-cn.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | logo 4 | 5 |

6 | 7 | # VuePress 8 | 9 | > Minimalistic docs generator with Vue component based layout system 10 | 11 | https://vuepress.vuejs.org/ 12 | 13 | ## Features 14 | 15 | - [Built-in markdown extensions](https://vuepress.vuejs.org/guide/markdown.html) optimized for technical documentation 16 | - [Ability to leverage Vue inside markdown files](https://vuepress.vuejs.org/guide/using-vue.html) 17 | - [Vue-powered custom theme system](https://vuepress.vuejs.org/guide/custom-themes.html) 18 | - Service Worker Integration 19 | - Google Analytics Integration 20 | - A default theme with: 21 | - Responsive layout 22 | - Optional Homepage 23 | - Automatic basic typeahead search 24 | - Customizable navbar and sidebar 25 | - Auto-generated GitHub link and page edit links 26 | 27 | ## Todo Features 28 | 29 | VuePress is still a work in progress. There are a few things that it currently does not support but are planned: 30 | 31 | - Multi-Language Support 32 | - Algolia DocSearch Integration 33 | - Blogging support 34 | 35 | Contributions are welcome! 36 | 37 | ## Development 38 | 39 | > Please make sure your version of Node.js is greater than 8. 40 | 41 | ``` bash 42 | yarn 43 | yarn dev # serves VuePress' own docs with itself 44 | ``` 45 | 46 | ## License 47 | 48 | MIT 49 | -------------------------------------------------------------------------------- /src/guide/assets.md: -------------------------------------------------------------------------------- 1 | # 静态资源处理 2 | 3 | ## 相对 URLs 4 | 5 | 所有 markdown 文件都会被编译到 Vue 组件中并由 webpack 处理,因此你**应该更倾向于**使用相对 URL 引用任意资源: 6 | 7 | ``` md 8 | ![An image](./image.png) 9 | ``` 10 | 11 | 这将和 `* .vue` 文件模板中的运作的方式相同。该图片资源将通过 `url-loader` 和 `file-loader` 进行处理,并被复制到生成的静态构建文件中的合适位置。 12 | 13 | 另外,你可以使用 `~` 前缀来明确指出这是一个 webpack 模块请求,这将允许你使用 webpack 别名或 npm 依赖关系引用文件: 14 | 15 | ``` md 16 | ![Image from alias](~@alias/image.png) 17 | ![Image from dependency](~some-dependency/image.png) 18 | ``` 19 | 20 | webpack 别名可以通过 `.vuepress/config.js` 中的 [configureWebpack](/config/#configurewebpack) 进行配置。例如: 21 | 22 | ``` js 23 | module.exports = { 24 | configureWebpack: { 25 | resolve: { 26 | alias: { 27 | '@alias': 'path/to/some/dir' 28 | } 29 | } 30 | } 31 | } 32 | ``` 33 | 34 | ## 公共文件 35 | 36 | 有时,你可能需要提供静态资源,这些资源并没有在任何 markdown 或主题组件中直接引用 - 例如,favicons 和 PWA 图标。在这种情况下,你可以将它们放在 `.vuepress/public` 中,并且它们将被复制到生成目录的根目录。 37 | 38 | ## 基准 URL 39 | 40 | 如果你的网站部署到非根 URL,则需要在 `.vuepress/config.js` 中设置 `base` 选项。例如,如果你打算将你的网站部署到 `https://foo.github.io/bar/`,那么`base`应该设置为 `"/bar/"`(它应该始终以斜杠开始和结束)。 41 | 42 | 使用基准 URL,如果你想在 `.vuepress/public` 中引用图片,则必须使用像 `/bar/image.png` 这样的 URL。但是,如果你有朝一日会决定更改 `base` ,这样的路径就显得很脆弱了。为了解决这个问题,VuePress 提供了一个内置的帮助器 `$withBase`(注入到 Vue 的原型中),它可以生成正确的路径: 43 | 44 | ``` vue 45 | foo 46 | ``` 47 | 48 | 请注意,你不仅可以在主题组件中使用上述语法,还可以在 markdown 文件中使用上述语法。 49 | 50 | 另外,如果设置了 `base`,它会自动作为前缀拼接到 `.vuepress/config.js` 选项中的所有静态资源 URL 中。 51 | -------------------------------------------------------------------------------- /lib/markdown/snippet.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs') 2 | 3 | module.exports = function snippet (md, options = {}) { 4 | const root = options.root || process.cwd() 5 | function parser (state, startLine, endLine, silent) { 6 | const CH = '<'.charCodeAt(0) 7 | const pos = state.bMarks[startLine] + state.tShift[startLine] 8 | const max = state.eMarks[startLine] 9 | 10 | // if it's indented more than 3 spaces, it should be a code block 11 | if (state.sCount[startLine] - state.blkIndent >= 4) { 12 | return false 13 | } 14 | 15 | for (let i = 0; i < 3; ++i) { 16 | const ch = state.src.charCodeAt(pos + i) 17 | if (ch !== CH || pos + i >= max) return false 18 | } 19 | 20 | if (silent) { 21 | return true 22 | } 23 | 24 | const start = pos + 3 25 | const end = state.skipSpacesBack(max, pos) 26 | const rawPath = state.src.slice(start, end).trim().replace(/^@/, root) 27 | const filename = rawPath.split(/[{:\s]/).shift() 28 | const content = fs.existsSync(filename) ? fs.readFileSync(filename).toString() : 'Not found: ' + filename 29 | const meta = rawPath.replace(filename, '') 30 | 31 | state.line = startLine + 1 32 | 33 | const token = state.push('fence', 'code', 0) 34 | token.info = filename.split('.').pop() + meta 35 | token.content = content 36 | token.markup = '```' 37 | token.map = [startLine, startLine + 1] 38 | 39 | return true 40 | } 41 | 42 | md.block.ruler.before('fence', 'snippet', parser) 43 | } 44 | -------------------------------------------------------------------------------- /src/zh/miniapp/小程序事件.md: -------------------------------------------------------------------------------- 1 | # 小程序事件 2 | ##### 事件 3 | - 事件就是用户到界面(视图)的交互行为,移动端常见的交互行为(触屏,触摸移动,长按,键盘输入,多点触控,摇一摇,语音,各种状态事件,...., 重按) 4 | ##### 事件绑定 5 | 6 | ``` 7 | 在小程序中绑定事件使用 bind不会阻止冒泡, catch阻止冒泡 capture-bind使用捕获 capture-catch 8 | 两种写法 9 | bind:tap bindtap 10 | catch:tap catchtap 11 | 12 | 例如: 点我 当用户点击该组件的时候会在该页面对应的Page中找到相应的事件处理函数。在事件处理函数中会得到事件对象event 13 | 14 | Page( 15 | eventCallback (event) { 16 | Console.log(event) 17 | } 18 | ) 19 | 20 | Event对象 21 | 22 | { 23 | //基础属性 24 | Type: 事件类型, 25 | timeStamp: 事件生成时的时间戳 26 | Target: { 27 | Id: ,事件源组件的id 28 | tagName: , 当前组件的类型 29 | Dataset: 事件源组件上由data-开头的自定义属性组成的集合 (可用作事件传参) 30 | } 触发事件的组件的一些属性值集合 31 | currentTarget: 当前组件的一些属性值集合, 32 | 33 | detail: 额外信息 {x, y} 触摸点的位置 34 | 35 | //触控信息 36 | Touches: 手指头列表 37 | changenTouches: 动了的手指头的列表 38 | } 39 | ``` 40 | ##### 事件分类 41 | - 事件分为冒泡事件和非冒泡事件 42 | 1. 冒泡事件:当一个组件上的事件被触发后,该事件会向父节点传递。 43 | 2. 非冒泡事件:当一个组件上的事件被触发后,该事件不会向父节点传递。(例如:表单相关事件,加载相关事件) 44 | ##### 交互事件 45 | 46 | ``` 47 | 触摸 touchstart 48 | 移动 touchmove 49 | 打断 touchcancel 50 | 离开 touchend 51 | 轻触 tap 52 | 长按(超过350毫秒) longtab longpress 53 | 重按(3D Touch设备) touchforcechange 54 | ``` 55 | ##### 监听事件 56 | 57 | ``` 58 | transitionend 会在 WXSS transition 或 wx.createAnimation 动画结束后触发 59 | animationstart 会在一个 WXSS animation 动画开始时触发 60 | animationiteration 会在一个 WXSS animation 一次迭代结束时触发 61 | animationend 会在一个 WXSS animation 动画完成时触发 62 | 63 | ``` 64 | -------------------------------------------------------------------------------- /src/zh/standard/Start.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar: auto 3 | sidebarDepth: 2 4 | --- 5 | ## 环境配置 6 | ### 重装系统 7 | - [系统下载](https://msdn.itellyou.cn/) 8 | 9 | ### Git环境 10 | - [安装和公钥/私钥的配置](https://www.cnblogs.com/joyho/articles/4062574.html) 11 | - [常用命令](https://github.com/jasonandjay/project) 12 | - 提交之前需要配置全局用户和密码,git commit的时候需要 13 | ``` 14 | git config --global user.name "your name" 15 | git config --global user.email "you email" 16 | ``` 17 | ### Node环境 18 | - [安装教程](https://www.cnblogs.com/zhouyu2017/p/6485265.html) 19 | - 可以查看到node版本和npm版本即可 20 | - cnpm配置 21 | ``` 22 | npm install -g cnpm --registry=https://registry.npm.taobao.org 23 | ``` 24 | - 进阶:可以使用[nvm](https://github.com/creationix/nvm)管理window上的node版本 25 | 26 | 27 | ## 开发工具 28 | ### ConEmu安装 29 | - [安装教程](https://www.jianshu.com/p/264e75aef8bb) 30 | - 多个终端方便快速切换 31 | ### VSCode 32 | - [汉化教程](https://jingyan.baidu.com/article/7e44095377c9d12fc1e2ef5b.html) 33 | ### 抓包工具 Charles 34 | - [安装和破解](https://zhubangbang.com/charles-crack-version-free-download-and-install-tutorial.html) 35 | - [使用教程](http://www.cnblogs.com/jiayuchn-test/p/8875105.html) 36 | ### 小飞机 ShadowSocks 37 | - [安装教程](https://gitman6.github.io/cshow/windows.html) 38 | - 使用以前的账号配置服务器 39 | ### Chrome 40 | - 未翻墙,可以去[应用中心下载](https://pc.qq.com/detail/1/detail_2661.html) 41 | - 已翻墙,去官网下载安装,后续安装插件 42 | - 常用插件如下 43 | 44 | ![插件列表](/study/FastStoneEditor.jpg) 45 | 46 | ## 沟通工具 47 | - 邮箱 48 | - 钉钉 49 | 50 | ## 如何解决问题 51 | ### 常用方法 52 | ![秘籍](/study/baidu.png) 53 | ### 进阶方法 54 | - 查看官方文档 55 | - 查看Github issues 56 | - 使用Google搜索问题 -------------------------------------------------------------------------------- /src/zh/guide/basic-config.md: -------------------------------------------------------------------------------- 1 | # 基本配置 2 | 3 | ## 配置文件 4 | 5 | 如果没有任何配置,这个网站将会是非常局限的,用户也无法在你的网站上自由导航。为了更好地自定义你的网站,让我们首先在你的文档目录下创建一个 `.vuepress` 目录,所有 VuePress 相关的文件都将会被放在这里。你的项目结构可能是这样: 6 | 7 | ``` 8 | . 9 | ├─ study 10 | │ ├─ README.md 11 | │ └─ .vuepress 12 | │ └─ config.js 13 | └─ package.json 14 | ``` 15 | 16 | 一个 VuePress 网站必要的配置文件是 `.vuepress/config.js`,它应该导出一个 JavaScript 对象: 17 | 18 | ``` js 19 | module.exports = { 20 | title: 'Hello VuePress', 21 | description: 'Just playing around' 22 | } 23 | ``` 24 | 25 | 对于上述的配置,如果你运行起 dev server,你应该能看到一个页面,它包含一个页头,里面包含一个标题和一个搜索框。VuePress 内置了基于 headers 的搜索 —— 它会自动为所有页面的标题、`h2` 和 `h3` 构建起一个简单的搜索索引。 26 | 27 | 参见 [配置](../config/) 来查看所有可配置的选项。 28 | 29 | ::: tip 其他配置格式 30 | 你也可以使用 YAML (`.vuepress/config.yml`) 或是 TOML (`.vuepress/config.toml`) 格式的配置文件。 31 | ::: 32 | 33 | ## 主题配置 34 | 35 | 一个 VuePress 主题应该负责整个网站的布局和交互细节。在 VuePress 中,目前自带了一个默认的主题(正是你现在所看到的),它是为技术文档而设计的。同时,默认主题提供了一些选项,让你可以去自定义导航栏(navbar)、 侧边栏(sidebar)和 首页(homepage) 等,详情请参见 [默认主题](../default-theme-config/README.md) 。 36 | 37 | 如果你想开发一个自定义主题,可以参考 [自定义主题](./custom-themes.md)。 38 | 39 | 40 | ## 应用级别的配置 41 | 42 | 由于 VuePress 是一个标准的 Vue 应用,你可以通过创建一个 `.vuepress/enhanceApp.js` 文件来做一些应用级别的配置,当该文件存在的时候,会被导入到应用内部。`enhanceApp.js` 应该 `export default` 一个钩子函数,并接受一个包含了一些应用级别属性的对象作为参数。你可以使用这个钩子来安装一些附加的 Vue 插件、注册全局组件,或者增加额外的路由钩子等: 43 | 44 | ``` js 45 | export default ({ 46 | Vue, // VuePress 正在使用的 Vue 构造函数 47 | options, // 附加到根实例的一些选项 48 | router, // 当前应用的路由实例 49 | siteData // 站点元数据 50 | }) => { 51 | // ...做一些其他的应用级别的优化 52 | } 53 | ``` 54 | -------------------------------------------------------------------------------- /docs/assets/js/50.6ea8d75d.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[50],{164:function(t,a,s){"use strict";s.r(a);var r=s(0),e=Object(r.a)({},function(){this.$createElement;this._self._c;return this._m(0)},[function(){var t=this,a=t.$createElement,s=t._self._c||a;return s("div",{staticClass:"content"},[s("h1",{attrs:{id:"props"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#props","aria-hidden":"true"}},[t._v("#")]),t._v(" Props")]),t._v(" "),s("h4",{attrs:{id:"_1、和props相关"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#_1、和props相关","aria-hidden":"true"}},[t._v("#")]),t._v(" 1、和props相关")]),t._v(" "),s("ul",[s("li",[t._v("只读,不准修改")]),t._v(" "),s("li",[t._v("componentWillReceiveProps / 生命周期")]),t._v(" "),s("li",[t._v("propTypes")]),t._v(" "),s("li",[t._v("defaultProps")]),t._v(" "),s("li",[t._v("children")])]),t._v(" "),s("h4",{attrs:{id:"_2、类型检查"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#_2、类型检查","aria-hidden":"true"}},[t._v("#")]),t._v(" 2、类型检查")]),t._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[t._v("import PropTypes from 'prop-types';\n\nList.propTypes = {\n list:PropTypes.array/object/number/string\n}\n")])])]),s("h4",{attrs:{id:"_3、默认值"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#_3、默认值","aria-hidden":"true"}},[t._v("#")]),t._v(" 3、默认值")]),t._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[t._v("List.defaultProps = {\n list:[{},{},{}]\n}\n")])])])])}],!1,null,null,null);a.default=e.exports}}]); -------------------------------------------------------------------------------- /src/zh/algorithm/Charpter6.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar: auto 3 | sidebarDepth: 2 4 | --- 5 | 6 | # 第6章 数学趣题(二) 7 | 8 | ## 6.1 连续整数固定和问题 9 | ![移数字游戏](/study/algorithm/6.1.png) 10 | 11 | ## 6.2 表示成两个数的平方和 12 | 已知一个正整数N,编写一个程序,找出所有满足X²+Y²=N的正整数对X和Y。 13 | 14 | ## 6.3 具有特殊性质的数 15 | 有这样一个4位数abed,它具有这样的性质abcd=(ab+cd)², 其中, ab和cd为两个2位数,求这个4位数abcd. 16 | 17 | ## 6.4 验证角谷猜想 18 | 角谷猜想的内容为:任意给定一个自然数,若它为偶数则除以2,若它为奇数则乘3加1,得到一个新的自然数,按照这样的计算方法计算下去,若干次后得到的结果必然为1.编写程序对角谷猜想的正确性加以验证。 19 | 20 | ## 6.5 验证四方定理 21 | 四方定理是数论中的重要定理,它可以叙述为:所有自然数最多只要4个数的平方和就可以表示,编写一个程序验证四方定理。 22 | 23 | ## 6.6 递归法寻找最小值 24 | 编写一个程序,要求从一个整数序列中找出最小的元素,并用递归的方法实现。 25 | 26 | ## 6.7 寻找同构数 27 | 正整数n若是它平方数的尾部,则称n为同构数。例如, 6是其平方数36的尾部, 76是其平方数5776的尾部,因此6与76都是同构数。编写一个程序,找出1000以内的同构数。 28 | 29 | ## 6.8 验证尼科彻斯定理 30 | 尼科彻斯定理可以叙述为:任何一个整数的立方都可以表示成一串连续奇数的和。这里要注意,这些奇数一定是要连续的,例如1,3,5,7,9... 31 | 32 | ## 6.9 三重回文数字 33 | 找出11~999之间的所有的三重回文数字。所谓三重回文数a就是指a,a²,a³都是回文数字。 34 | 35 | ## 6.10 马克思手稿中的数学题 36 | 伟大的思想家马克思的手稿中有这样一道有趣的数学题:有30个人,其中有男人、女人和小孩。他们在一家饭馆中吃饭,共花费50先令。如果每个男人吃饭要花3先令,每个女人要花2先令,每个小孩花要花1先令,问男人、女人、小孩各多少人? 37 | 38 | ## 6.11 渔夫捕鱼问题 39 | A,B,C,D,E 5个渔夫夜间合伙捕鱼,凌晨时都疲倦不堪,各自在河边的树丛中找地方睡着了。待日上三竿,渔夫A第一个醒来,他将鱼分作5份,把多余的一条扔回河中,拿自己的一份回家去了。渔夫B第二个醒来,也将鱼分作5份,扔掉多余的一条,拿走自己的一份,接着C,D,E依次醒来,也都按同样的办法分鱼,问5个渔夫至少合伙捕了多少条鱼?试编程序算出。 40 | 41 | ## 6.12 寻找假币 42 | 一个国王要赏赐给一个大臣30枚金币,但是其中有一枚是假币。国王提出要求:只能用一个天平作为测量工具,并用尽量少的比较次数找出这校假币,那么余下的29枚金币就赏赐给这个大臣;否则这个大臣将得不到赏赐。已知假币要比真币的分量略轻一些。聪明的大臣思考片刻,很快用天平找出了这枚假币,于是得到了剩下的29枚金币。你知道这位大臣是如何找到假币的吗?请编写一个程序模拟找假币的过程,注意用尽量少的比较次数找出这枚假币。 43 | 44 | ## 6.13 计算组合数 45 | 编写一个程序,计算组合数 46 | ![计算组合数](/study/algorithm/6.13.png) 47 | -------------------------------------------------------------------------------- /src/zh/miniapp/小程序路由.md: -------------------------------------------------------------------------------- 1 | # 小程序路由 2 | ##### 1、路由管理 3 | - 在小程序中所有页面的路由全部由框架进行管理,框架以栈的形式维护了当前的所有页面。 4 | ##### 2、栈(计算机术语) 5 | - 栈(stack)又名堆栈,它是一种运算受限的线性表。其限制是仅允许在表的一端进行插入和删除运算。这一端被称为栈顶,相对地,把另一端称为栈底。向一个栈插入新元素又称作进栈、入栈或压栈,它是把新元素放到栈顶元素的上面,使之成为新的栈顶元素;从一个栈删除元素又称作出栈或退栈,它是把栈顶元素删除掉,使其相邻的元素成为新的栈顶元素。 6 | - 可进可出(进是添加,处删除),也就意味这小程序中可以跳转新页面,可以后退,但是不能前进 7 | ##### 3、浏览器如何管理浏览记录 8 | - 浏览器以浏览新网页的形式将所有浏览都保留在历史记录,任何浏览都会保存,后退不会删除浏览器记录,也就意味着可以前进 9 | 10 | ``` 11 | 场景 12 | A页面 A页面进栈 13 | A页面 -> B页面 B页面进栈 14 | B页面 -> C页面 C页面进栈 15 | C页面后退 C页面出栈 16 | B页面 -> D页面 D页面进栈 17 | [A,B,D] 18 | 19 | D页面打开 A页面 在一个A页面进栈 20 | ``` 21 | ##### 4、getCurrentPages() 22 | - 该函数用于获取当前页面栈的实例,以数组形式按栈的顺序给出,第一个元素为首页,最后一个元素为当前页面。在小程序中栈最多只能维护10个数据 23 | ##### 5、栈的表现 24 | - 打开新页面 -> 进栈 25 | - 后退 -> 当前页面出栈 26 | - 重定向 -> 当期页面出栈新页面入栈 27 | - 重加载 -> 页面全部出栈保留当期页面栈 28 | - Tab 切换 -> 页面全部出栈,只留下新的 Tab 页面 29 | 30 | ##### 5、路由跳转方式 31 | - 在小程序中路由跳转方式有两种(组件跳转,api跳转) 32 | 33 | 跳转形式 | Api|组件 34 | ---|---|--- 35 | 打开新页面 | wx.navigateTo(‘路径’)| <\navigator open-type="navigateTo"/> 36 | 页面重定向 | wx.redirectTo|<\navigator open-type="redirectTo"/> 37 | 页面返回|wx.navigateBack|<\navigator open-type="navigateBack"> 38 | Tab 切换|wx.switchTab|<\navigator open-type="switchTab"/> 39 | 重启动|wx.reLaunch|<\navigator open-type="reLaunch"/> 40 | 41 | #### 注意: 42 | - navigateTo, redirectTo 只能打开非 tabBar 页面。 43 | - switchTab 只能打开 tabBar 页面。 44 | - reLaunch 可以打开任意页面。 45 | - 页面底部的 tabBar 由页面决定,即只要是定义为 tabBar 的页面,底部都有 tabBar。 46 | - 调用页面路由带的参数可以在目标页面的onLoad中获取 47 | - 页面只有在出栈后才会被卸载也就是执行onUnload, tab页面只有在程序卸载的时候才会卸载 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/zh/react/高阶组件.md: -------------------------------------------------------------------------------- 1 | # 高阶组件 2 | ##### 1、什么是高阶组件? 3 | - 高阶组件就是一个 React 组件包裹着另外一个 React 组件 4 | - 因为要访问它的内部状态,所以要用到继承 5 | - 高阶组件就是一个函数,它接受另一个组件作为参数,并返回一个新的组件。 6 | - 当 React 组件被包裹时(warped),高阶组件会返回一个增强的 React 组件。 7 | - 高阶组件让代码更具有复用性、逻辑性和抽象特性。 8 | ##### 2、侵入式 9 | - 利用super传递下去 10 | 11 | ``` 12 | import React from 'react'; 13 | import Loding from '../common/loading'; 14 | 15 | // 侵入式 16 | // 因为要访问它的内部状态,所以要用到继承,继承他的父级 17 | export default (WrapComponent)=>{ 18 | return class extends WrapComponent{ 19 | render(){ 20 | if(this.state.isLoading){ 21 | return 22 | }else{ 23 | return super.render() 24 | } 25 | } 26 | } 27 | } 28 | ``` 29 | 30 | ##### 3、非侵入式 31 | - 利用...传递下去 32 | 33 | hoc/widthAd.jsx 34 | 35 | ``` 36 | import React from 'react'; 37 | 38 | // 非侵入式 39 | // WrapComponent 被包裹的组件 40 | export default (WrapComponent)=>{ 41 | return class extends React.Component{ 42 | render(){ 43 | return
44 |
45 |

请下载淘票票

46 | 下载 47 |
48 | 49 |
50 | } 51 | } 52 | } 53 | 54 | 用的时候直接引入这个文件,然后抛出 export default widthAd(Tab) 55 | ``` 56 | 57 | ##### 4、为什么要使用高阶组件? 58 | - 为了代码的复用性,减少代码的冗余 59 | 60 | #### js继承的几种方式 61 | 1. function (this指向当前的function) 62 | ``` 63 | function A(){ 64 | 65 | } 66 | A.protytype.add = ()=>{ 67 | 68 | } 69 | ``` 70 | 71 | -------------------------------------------------------------------------------- /docs/assets/js/35.0d7b47e4.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[35],{179:function(a,t,e){"use strict";e.r(t);var s=e(0),r=Object(s.a)({},function(){this.$createElement;this._self._c;return this._m(0)},[function(){var a=this,t=a.$createElement,e=a._self._c||t;return e("div",{staticClass:"content"},[e("h1",{attrs:{id:"思维导图版知识点总结"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#思维导图版知识点总结","aria-hidden":"true"}},[a._v("#")]),a._v(" 思维导图版知识点总结")]),a._v(" "),e("h2",{attrs:{id:"vue"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#vue","aria-hidden":"true"}},[a._v("#")]),a._v(" Vue")]),a._v(" "),e("p",[e("img",{attrs:{src:"http://assets.processon.com/chart_image/5af6a37ae4b0a0f0f1a05a36.png",alt:"vue"}})]),a._v(" "),e("h2",{attrs:{id:"react"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#react","aria-hidden":"true"}},[a._v("#")]),a._v(" React")]),a._v(" "),e("p",[e("img",{attrs:{src:"http://assets.processon.com/chart_image/5b33428ae4b0a8a7ffb98bd7.png?_=1552542663250",alt:"react"}})]),a._v(" "),e("h2",{attrs:{id:"阶段一"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#阶段一","aria-hidden":"true"}},[a._v("#")]),a._v(" 阶段一")]),a._v(" "),e("p",[e("img",{attrs:{src:"http://assets.processon.com/chart_image/5bac8350e4b0bd4db94e9514.png?_=1552542696718",alt:"实训一"}})]),a._v(" "),e("h2",{attrs:{id:"阶段二"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#阶段二","aria-hidden":"true"}},[a._v("#")]),a._v(" 阶段二")]),a._v(" "),e("p",[e("img",{attrs:{src:"http://assets.processon.com/chart_image/5bc0198fe4b06fc64b17fa15.png?_=1552542798104",alt:"实训二"}})])])}],!1,null,null,null);t.default=r.exports}}]); -------------------------------------------------------------------------------- /docs/assets/js/49.ebed9df6.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[49],{165:function(e,t,i){"use strict";i.r(t);var v=i(0),l=Object(v.a)({},function(){this.$createElement;this._self._c;return this._m(0)},[function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("div",{staticClass:"content"},[i("h1",{attrs:{id:"mvvm"}},[i("a",{staticClass:"header-anchor",attrs:{href:"#mvvm","aria-hidden":"true"}},[e._v("#")]),e._v(" MVVM")]),e._v(" "),i("h4",{attrs:{id:"_1、mvvm是什么?"}},[i("a",{staticClass:"header-anchor",attrs:{href:"#_1、mvvm是什么?","aria-hidden":"true"}},[e._v("#")]),e._v(" 1、MVVM是什么?")]),e._v(" "),i("ol",[i("li",[e._v("MVVM是Model-View-ViewModel的简写")]),e._v(" "),i("li",[e._v("它本质上是MVC 的改进版")]),e._v(" "),i("li",[e._v("MVVM(Model-View-ViewModel)框架的由来是MVP(Model-View-Presenter)模式与WPF结合的应用方式时发展演变过来的一种新型架构框架")])]),e._v(" "),i("h4",{attrs:{id:"_2、mvvm优点"}},[i("a",{staticClass:"header-anchor",attrs:{href:"#_2、mvvm优点","aria-hidden":"true"}},[e._v("#")]),e._v(" 2、MVVM优点")]),e._v(" "),i("ul",[i("li",[i("blockquote",[i("p",[e._v("MVVM模式和MVC模式一样,主要目的是分离视图(View)和模型(Model),有几大优点")])])])]),e._v(" "),i("ol",[i("li",[i("strong",[e._v("低耦合")]),e._v(':视图(View)可以独立于Model变化和修改,一个ViewModel可以绑定到不同的"View"上,当View变化的时候Model可以不变,当Model变化的时候View也可以不变')]),e._v(" "),i("li",[i("strong",[e._v("可重用性")]),e._v(":你可以把一些视图逻辑放在一个ViewModel里面,让很多view重用这段视图逻辑")]),e._v(" "),i("li",[i("strong",[e._v("独立开发")]),e._v(":开发人员可以专注于业务逻辑和数据的开发(ViewModel),设计人员可以专注于页面设计,使用Expression Blend可以很容易设计界面并生成xml代码")]),e._v(" "),i("li",[i("strong",[e._v("可测试")]),e._v(":界面素来是比较难于测试的,而现在测试可以针对ViewModel来写")])])])}],!1,null,null,null);t.default=l.exports}}]); -------------------------------------------------------------------------------- /src/zh/guide/assets.md: -------------------------------------------------------------------------------- 1 | # 静态资源 2 | 3 | ## 相对路径 4 | 5 | 所有的 Markdown 文件都会被 webpack 编译成 Vue 组件,因此你可以,并且**应该更倾向于**使用相对路径(Relative URLs)来引用所有的静态资源: 6 | 7 | ``` md 8 | ![An image](./image.png) 9 | ``` 10 | 11 | 同样地,这在 `*.vue` 文件的模板中一样可以工作,图片将会被 `url-loader` 和 `file-loader` 处理,在运行生成静态文件的构建任务时,文件会被复制到正确的位置。 12 | 13 | 除此之外,你也使用 `~` 前缀来明确地指出这是一个 webpack 的模块请求,这将允许你通过 webpack 别名来引用文件或者 npm 的依赖: 14 | 15 | ``` md 16 | ![Image from alias](~@alias/image.png) 17 | ![Image from dependency](~some-dependency/image.png) 18 | ``` 19 | 20 | Webpack 的别名可以通过 `.vuepress/config.js` 中 [configureWebpack](../config/README.md#configurewebpack) 来配置,如: 21 | 22 | ``` js 23 | module.exports = { 24 | configureWebpack: { 25 | resolve: { 26 | alias: { 27 | '@alias': 'path/to/some/dir' 28 | } 29 | } 30 | } 31 | } 32 | ``` 33 | 34 | ## 公共文件 35 | 36 | 有时,你可能需要提供一个静态资源,但是它们并不直接被你的任何一个 markdown 文件或者主题组件引用 —— 举例来说,favicons 和 PWA 的图标,在这种情形下,你可以将它们放在 `.vuepress/public` 中, 它们最终会被复制到生成的静态文件夹中。 37 | 38 | ## 基础路径 39 | 40 | 如果你的网站会被部署到一个**非根路径**,你将需要在 `.vuepress/config.js` 中设置 `base`,举例来说,如果你打算将你的网站部署到 `https://foo.github.io/bar/`,那么 `base` 的值就应该被设置为 `"/bar/"` (应当总是以斜杠开始,并以斜杠结束)。 41 | 42 | 有了基础路径(Base URL),如果你希望引用一张放在 `.vuepress/public` 中的图片,你需要使用这样路径:`/bar/image.png`,然而,一旦某一天你决定去修改 `base`,这样的路径引用将会显得异常脆弱。为了解决这个问题,VuePress 提供了内置的一个 helper `$withBase`(它被注入到了 Vue 的原型上),可以帮助你生成正确的路径: 43 | 44 | ``` vue 45 | foo 46 | ``` 47 | 48 | 值得一提的是,你不仅可以在你的 Vue 组件中使用上述的语法,在 Markdown 文件中亦是如此。 49 | 50 | 最后补充一句,一个 `base` 路径一旦被设置,它将会自动地作为前缀插入到 `.vuepress/config.js` 中所有以 `/` 开始的资源路径中。 51 | -------------------------------------------------------------------------------- /lib/markdown/highlightLines.js: -------------------------------------------------------------------------------- 1 | // Modified from https://github.com/egoist/markdown-it-highlight-lines 2 | 3 | const RE = /{([\d,-]+)}/ 4 | const wrapperRE = /^
/
 5 | 
 6 | module.exports = md => {
 7 |   const fence = md.renderer.rules.fence
 8 |   md.renderer.rules.fence = (...args) => {
 9 |     const [tokens, idx, options] = args
10 |     const token = tokens[idx]
11 | 
12 |     const rawInfo = token.info
13 |     if (!rawInfo || !RE.test(rawInfo)) {
14 |       return fence(...args)
15 |     }
16 | 
17 |     const langName = rawInfo.replace(RE, '').trim()
18 |     // ensure the next plugin get the correct lang.
19 |     token.info = langName
20 | 
21 |     const lineNumbers = RE.exec(rawInfo)[1]
22 |       .split(',')
23 |       .map(v => v.split('-').map(v => parseInt(v, 10)))
24 | 
25 |     const code = options.highlight
26 |       ? options.highlight(token.content, langName)
27 |       : token.content
28 | 
29 |     const rawCode = code.replace(wrapperRE, '')
30 |     const highlightLinesCode = rawCode.split('\n').map((split, index) => {
31 |       const lineNumber = index + 1
32 |       const inRange = lineNumbers.some(([start, end]) => {
33 |         if (start && end) {
34 |           return lineNumber >= start && lineNumber <= end
35 |         }
36 |         return lineNumber === start
37 |       })
38 |       if (inRange) {
39 |         return `
 
` 40 | } 41 | return '
' 42 | }).join('') 43 | 44 | const highlightLinesWrapperCode = 45 | `
${highlightLinesCode}
` 46 | 47 | return highlightLinesWrapperCode + code 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/zh/standard/Cooperation.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar: auto 3 | sidebarDepth: 2 4 | --- 5 | # 前后端是如何交互的 6 | iOS,H5,安卓等前端开发的如何跟后台进行交互? 7 | 应该怎么去规避一些不该属于自己的任务而被后台强加于自己? 8 | 9 | ## 1.前端请求数据URL由谁来写? 10 | 在开发中,URL主要是由后台来写的,写好了给前端开发者.如果后台在查询数据,需要借助查询条件才能查询到前端需要的数据时,这时后台会要求前端提供相关的查询参数,这里的查询参数也就是URL请求的参数。 11 | 12 | ## 2.接口文档主要由谁来写? 13 | 接口文档也是主要由后台开发者来写的,因为直接跟数据打交道的就是后台,后台是最清楚,数据库里面有什么数据,能返回什么数据.前端开发只是数据的被动接受者.所以接口文档也主要是由后台来完成的,前端只是接口文档的使用者,使用过程中,发现返回的数据不对,则需要跟后台进行商量,由后台来修改.切记 前端不要随意更改接口文档,除非在取得后台开发人员的同意的情况下.总的来讲,接口文档主要由后台来设计,修改,前端开发者起到了辅助的作用. 14 | 15 | ## 3.前端开发与后台交互的数据格式主要是什么? 16 | 主要是JSON 17 | XML现在用的不多 18 | 19 | ## 4.前端开发的后台交互原理? 20 | 在项目的时候,我们前后端会大概说一下接口地址,前端请求的参数,后端返回的参数,然后大家就开始写,写的差不多的时候,大家调一下接口看一下返回的数据,没问题就可以了。 21 | 22 | ## 5.前端请求参数的形式 23 | GET和POST两种方式, 也会采用RESTful架构, 通过请求方式表示用户行为 24 | 对安全性不高 采用get方便 25 | post要比get安全 26 | GET - 从指定的服务器中获取数据 27 | POST - 提交数据给指定的服务器处理 28 | 29 | ## 6.前端应该告知后台哪些有效信息,后台才能返回前端想的数据的呢? 30 | 先将要展示的页面内容进行模块划分,将模块的内容提取出来,以及方便前端的一些标志值等,将所有想要的内容和逻辑告知后端,后端就会去数据库里面去查找相应的数据表中去获得相应的内容,或者图片地址信息。 31 | URL中的参数主要是根据后台需要, 32 | 如果后台需要一个参数作为查询的辅助条件 前端在URL数据请求时就传递参数。参数前面?几个参数中间& 33 | 34 | ## 7.我们应该怎么把页面这些信息有效传达给后台,以及后台是如何获取到这些数据? 35 | 总的来讲:所有前端请求的URL后面的参数,都是辅助后台数据查询的.如果不需要参数,那么后台就会直接给个URL给前端. 36 | 37 | ## 8.前端应该如何回拒一些本不属于自己做的一些功能需求或任务? 38 | 在与后台打交道中,我们经常遇到这种情况,有时候明明后台来处理某个事件很简单,后台非要你来做,这时候我们应该懂得去回绝他. 39 | 原则:前端就是负责把数据展示在页面上 40 | 发挥:这就需要我们对一个需求,一个任务的要有清晰认识了,如果对任务含糊不清,自己都没搞明白,你只能受后台摆布了.最后也会因为任务没有完成而备受责难了. 41 | 42 | ## 9.当前端在调用数据接口时,发现有些数据不是我们想要的,那么前端应该怎么办呢或者怎么跟后台讲呢? 43 | 首先要把请求的URL和返回的数据以及在页面的展示的情况给跟后台看,这样有理有据,后台开发人员是不会说什么的,否则,后台会很不耐烦的,甚至骂你的可能都有,本身做后台比较难,尤其在查询数据,取数据,封装数据方面都比较难处理. 44 | 45 | ## 10.为什么需要在请求的时候传入参数? 46 | 因为后台在查询数据库的时候需要条件查询。 -------------------------------------------------------------------------------- /lib/prepare/loadConfig.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs-extra') 2 | const path = require('path') 3 | const yamlParser = require('js-yaml') 4 | const tomlParser = require('toml') 5 | 6 | module.exports = function loadConfig (vuepressDir, bustCache = true) { 7 | const configPath = path.resolve(vuepressDir, 'config.js') 8 | const configYmlPath = path.resolve(vuepressDir, 'config.yml') 9 | const configTomlPath = path.resolve(vuepressDir, 'config.toml') 10 | 11 | if (bustCache) { 12 | delete require.cache[configPath] 13 | } 14 | 15 | // resolve siteConfig 16 | let siteConfig = {} 17 | if (fs.existsSync(configYmlPath)) { 18 | siteConfig = parseConfig(configYmlPath) 19 | } else if (fs.existsSync(configTomlPath)) { 20 | siteConfig = parseConfig(configTomlPath) 21 | } else if (fs.existsSync(configPath)) { 22 | siteConfig = require(configPath) 23 | } 24 | 25 | return siteConfig 26 | } 27 | 28 | function parseConfig (file) { 29 | const content = fs.readFileSync(file, 'utf-8') 30 | const [extension] = /.\w+$/.exec(file) 31 | let data 32 | 33 | switch (extension) { 34 | case '.yml': 35 | case '.yaml': 36 | data = yamlParser.safeLoad(content) 37 | break 38 | 39 | case '.toml': 40 | data = tomlParser.parse(content) 41 | // reformat to match config since TOML does not allow different data type 42 | // https://github.com/toml-lang/toml#array 43 | const format = [] 44 | if (data.head) { 45 | Object.keys(data.head).forEach(meta => { 46 | data.head[meta].forEach(values => { 47 | format.push([meta, values]) 48 | }) 49 | }) 50 | } 51 | data.head = format 52 | break 53 | } 54 | 55 | return data || {} 56 | } 57 | -------------------------------------------------------------------------------- /lib/webpack/createServerConfig.js: -------------------------------------------------------------------------------- 1 | module.exports = function createServerConfig (options, cliOptions) { 2 | const fs = require('fs') 3 | const path = require('path') 4 | const WebpackBar = require('webpackbar') 5 | const createBaseConfig = require('./createBaseConfig') 6 | const VueSSRServerPlugin = require('vue-server-renderer/server-plugin') 7 | const CopyPlugin = require('copy-webpack-plugin') 8 | 9 | const config = createBaseConfig(options, cliOptions, true /* isServer */) 10 | const { sourceDir, outDir } = options 11 | 12 | config 13 | .target('node') 14 | .externals([/^vue|vue-router$/]) 15 | .devtool('source-map') 16 | 17 | // no need to minimize server build 18 | config.optimization.minimize(false) 19 | 20 | config 21 | .entry('app') 22 | .add(path.resolve(__dirname, '../app/serverEntry.js')) 23 | 24 | config.output 25 | .filename('server-bundle.js') 26 | .libraryTarget('commonjs2') 27 | 28 | config 29 | .plugin('ssr-server') 30 | .use(VueSSRServerPlugin, [{ 31 | filename: 'manifest/server.json' 32 | }]) 33 | 34 | const publicDir = path.resolve(sourceDir, '.vuepress/public') 35 | if (fs.existsSync(publicDir)) { 36 | config 37 | .plugin('copy') 38 | .use(CopyPlugin, [[ 39 | { from: publicDir, to: outDir } 40 | ]]) 41 | } 42 | 43 | if (!cliOptions.debug) { 44 | config 45 | .plugin('bar') 46 | .use(WebpackBar, [{ 47 | name: 'Server', 48 | color: 'blue', 49 | compiledIn: false 50 | }]) 51 | } 52 | 53 | if (options.siteConfig.chainWebpack) { 54 | options.siteConfig.chainWebpack(config, true /* isServer */) 55 | } 56 | 57 | return config 58 | } 59 | -------------------------------------------------------------------------------- /docs/assets/js/57.f1316fb6.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[57],{157:function(t,a,r){"use strict";r.r(a);var e=r(0),_=Object(e.a)({},function(){this.$createElement;this._self._c;return this._m(0)},[function(){var t=this,a=t.$createElement,r=t._self._c||a;return r("div",{staticClass:"content"},[r("h1",{attrs:{id:"组件通信"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#组件通信","aria-hidden":"true"}},[t._v("#")]),t._v(" 组件通信")]),t._v(" "),r("h4",{attrs:{id:"需要组件之进行通信的几种情况"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#需要组件之进行通信的几种情况","aria-hidden":"true"}},[t._v("#")]),t._v(" 需要组件之进行通信的几种情况")]),t._v(" "),r("ul",[r("li",[t._v("父组件向子组件通信")]),t._v(" "),r("li",[t._v("子组件向父组件通信")]),t._v(" "),r("li",[t._v("跨级组件通信")]),t._v(" "),r("li",[t._v("没有嵌套关系组件之间的通信")])]),t._v(" "),r("h5",{attrs:{id:"_1、父组件向子组件通信"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#_1、父组件向子组件通信","aria-hidden":"true"}},[t._v("#")]),t._v(" 1、父组件向子组件通信")]),t._v(" "),r("ul",[r("li",[t._v("通过props")])]),t._v(" "),r("h5",{attrs:{id:"_2、子组件向父组件通信"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#_2、子组件向父组件通信","aria-hidden":"true"}},[t._v("#")]),t._v(" 2、子组件向父组件通信")]),t._v(" "),r("ul",[r("li",[t._v("利用回调函数")]),t._v(" "),r("li",[t._v("利用自定义事件机制")])]),t._v(" "),r("h5",{attrs:{id:"_3、-跨级组件通信"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#_3、-跨级组件通信","aria-hidden":"true"}},[t._v("#")]),t._v(" 3、 跨级组件通信")]),t._v(" "),r("ul",[r("li",[t._v("层层组件传递props")]),t._v(" "),r("li",[t._v("使用context")])]),t._v(" "),r("h5",{attrs:{id:"_4、没有嵌套关系组件之间的通信"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#_4、没有嵌套关系组件之间的通信","aria-hidden":"true"}},[t._v("#")]),t._v(" 4、没有嵌套关系组件之间的通信")]),t._v(" "),r("ul",[r("li",[t._v("使用自定义事件机制")])])])}],!1,null,null,null);a.default=_.exports}}]); -------------------------------------------------------------------------------- /src/guide/basic-config.md: -------------------------------------------------------------------------------- 1 | # 配置 2 | 3 | ## 配置文件(config file) 4 | 5 | 不做任何配置的话,页面会显得过于简单,用户也无法方便地浏览网站。想要定制你的网站,首先需要在文档目录中创建一个 `.vuepress` 目录。这是放置所有 VuePress 特有(VuePress-specific) 文件的地方。你的项目结构可能长这样: 6 | 7 | ``` 8 | . 9 | ├─ docs 10 | │ ├─ README.md 11 | │ └─ .vuepress 12 | │ └─ config.js 13 | └─ package.json 14 | ``` 15 | 16 | 配置 VuePress 站点的基本文件是 `.vuepress/config.js`,其中导出一个 JavaScript 对象: 17 | 18 | ``` js 19 | module.exports = { 20 | title: 'Hello VuePress', 21 | description: 'Just playing around' 22 | } 23 | ``` 24 | 25 | 如果开发服务器正常运行,你应该看到该页面现在有一个 title 标题和一个搜索框。VuePress 带有内置的 基于 header 搜索(headers-based search) 的功能 - 它会自动从所有页面的 title, `h2` 和 `h3` header 标签中,建立一个简单的搜索索引。(译者注:此搜索是遍历 pages 数组的每一项,取出其中的 headers 数组,其中数组每项对应 markdown 标题,具体代码查看 /lib/default-theme/SearchBox.vue 的 suggestions 函数) 26 | 27 | 请查阅 [配置参考](../config/README.md) 以获取完整的选项列表。 28 | 29 | ::: tip 可替代的配置格式 30 | 你也可以使用 YAML(`.vuepress/config.yml`) 或 TOML(`.vuepress/config.toml`) 格式编写配置文件。 31 | ::: 32 | 33 | ## 主题配置(theme configuration) 34 | 35 | VuePress 主题,负责网站的所有布局和交互细节。VuePress 附带一个默认主题(你现在看到的就是),专门为技术文档设计。它暴露许多选项,允许你自定义导航栏(navbar)、侧边栏(sidebar)和主页(homepage)等。详细信息请查看 [默认主题配置](../default-theme-config/README.md) 页面。 36 | 37 | 如果你想开发自定义主题,请参考 [自定义主题](./custom-themes.md)。 38 | 39 | ## 应用程序级别的增强功能(app level enhancements) 40 | 41 | 由于 VuePress 应用是一个标准的 Vue 应用程序,所以你可以通过创建一个 `.vuepress/enhanceApp.js` 文件,来使用应用程序级别的增强功能,如果此文件存在,该文件将会被导入到该应用程序中。该文件应该通过 `export default` 方式导出一个钩子函数,它将接收一个含有一些应用程序级别值的对象作为参数。你可以使用这个钩子来安装额外的 Vue 插件,注册全局组件,或者添加额外的路由钩子: 42 | 43 | ``` js 44 | export default ({ 45 | Vue, // 当前 VuePress 应用所使用的 Vue 版本 46 | options, // 根 Vue 实例的选项 47 | router, // 应用程序的路由实例 48 | siteData // 网站元数据 49 | }) => { 50 | // ...使用应用程序级别的增强功能 51 | } 52 | ``` 53 | -------------------------------------------------------------------------------- /docs/assets/js/69.9e52d998.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[69],{218:function(t,e,r){"use strict";r.r(e);var a=r(0),u=Object(a.a)({},function(){this.$createElement;this._self._c;return this._m(0)},[function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{staticClass:"content"},[r("h1",{attrs:{id:"vue一些对比"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#vue一些对比","aria-hidden":"true"}},[t._v("#")]),t._v(" Vue一些对比")]),t._v(" "),r("h4",{attrs:{id:"一、methods和computed"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#一、methods和computed","aria-hidden":"true"}},[t._v("#")]),t._v(" 一、methods和computed")]),t._v(" "),r("ul",[r("li",[t._v("computed是计算属性,methods是方法。")]),t._v(" "),r("li",[t._v("computed计算属性是基于它们的依赖进行==缓存==的")]),t._v(" "),r("li",[t._v("computed只有在它的相关依赖发生改变时才会重新求值")]),t._v(" "),r("li",[t._v("而对于method ,只要发生重新渲染,method 调用==总会==执行该函数")]),t._v(" "),r("li",[t._v("==总之:数据量大,需要缓存的时候用computed;每次确实需要重新加载,不需要缓存时用methods==")])]),t._v(" "),r("h4",{attrs:{id:"二、computed和watch"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#二、computed和watch","aria-hidden":"true"}},[t._v("#")]),t._v(" 二、computed和watch")]),t._v(" "),r("ul",[r("li",[t._v("计算属性是==计算属性==,==侦听器watch==是侦听器watch")]),t._v(" "),r("li",[t._v("侦听器watch是侦听一个特定的值,当该值变化时执行特定的函数")])]),t._v(" "),r("h4",{attrs:{id:"三、-router和-route"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#三、-router和-route","aria-hidden":"true"}},[t._v("#")]),t._v(" 三、$router和$route")]),t._v(" "),r("ul",[r("li",[t._v("router为VueRouter的实例,相当于一个全局的路由器对象,里面含有很多属性和子对象")]),t._v(" "),r("li",[t._v("route相当于当前正在跳转的路由对象。。可以从里面获取name,path,params,query等")]),t._v(" "),r("li",[t._v("打印this.$route和this.$router,==两个同时存在==。")]),t._v(" "),r("li",[t._v("两者传参方式相同")])])])}],!1,null,null,null);e.default=u.exports}}]); -------------------------------------------------------------------------------- /lib/app/root-mixins/activeHeaderLinks.js: -------------------------------------------------------------------------------- 1 | import store from '@app/store' 2 | import throttle from 'lodash.throttle' 3 | 4 | export default { 5 | mounted () { 6 | window.addEventListener('scroll', this.onScroll) 7 | }, 8 | methods: { 9 | onScroll: throttle(function () { 10 | this.setActiveHash() 11 | }, 300), 12 | setActiveHash () { 13 | const sidebarLinks = [].slice.call(document.querySelectorAll('.sidebar-link')) 14 | const anchors = [].slice.call(document.querySelectorAll('.header-anchor')) 15 | .filter(anchor => sidebarLinks.some(sidebarLink => sidebarLink.hash === anchor.hash)) 16 | 17 | const scrollTop = Math.max( 18 | window.pageYOffset, 19 | document.documentElement.scrollTop, 20 | document.body.scrollTop 21 | ) 22 | 23 | for (let i = 0; i < anchors.length; i++) { 24 | const anchor = anchors[i] 25 | const nextAnchor = anchors[i + 1] 26 | 27 | const isActive = i === 0 && scrollTop === 0 || 28 | (scrollTop >= anchor.parentElement.offsetTop + 10 && 29 | (!nextAnchor || scrollTop < nextAnchor.parentElement.offsetTop - 10)) 30 | 31 | if (isActive && decodeURIComponent(this.$route.hash) !== decodeURIComponent(anchor.hash)) { 32 | store.disableScrollBehavior = true 33 | this.$router.replace(decodeURIComponent(anchor.hash), () => { 34 | // execute after scrollBehavior handler. 35 | this.$nextTick(() => { 36 | store.disableScrollBehavior = false 37 | }) 38 | }) 39 | return 40 | } 41 | } 42 | } 43 | }, 44 | beforeDestroy () { 45 | window.removeEventListener('scroll', this.onScroll) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /docs/assets/js/18.faddd431.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[18],{198:function(s,t,a){"use strict";a.r(t);var e=a(0),n=Object(e.a)({},function(){this.$createElement;this._self._c;return this._m(0)},[function(){var s=this,t=s.$createElement,a=s._self._c||t;return a("div",{staticClass:"content"},[a("h3",{attrs:{id:"像数-1-2-3-一样容易"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#像数-1-2-3-一样容易","aria-hidden":"true"}},[s._v("#")]),s._v(" 像数 1, 2, 3 一样容易")]),s._v(" "),a("div",{staticClass:"language-bash extra-class"},[a("pre",{pre:!0,attrs:{class:"language-bash"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[s._v("# 安装")]),s._v("\n"),a("span",{pre:!0,attrs:{class:"token function"}},[s._v("yarn")]),s._v(" global "),a("span",{pre:!0,attrs:{class:"token function"}},[s._v("add")]),s._v(" vuepress "),a("span",{pre:!0,attrs:{class:"token comment"}},[s._v("# 或者:npm install -g vuepress")]),s._v("\n\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[s._v("# 新建一个 markdown 文件")]),s._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[s._v("echo")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[s._v("'# Hello VuePress!'")]),s._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[s._v(">")]),s._v(" README.md\n\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[s._v("# 开始写作")]),s._v("\nvuepress dev "),a("span",{pre:!0,attrs:{class:"token keyword"}},[s._v(".")]),s._v("\n\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[s._v("# 构建静态文件")]),s._v("\nvuepress build "),a("span",{pre:!0,attrs:{class:"token keyword"}},[s._v(".")]),s._v("\n")])])]),a("div",{staticClass:"warning custom-block"},[a("p",{staticClass:"custom-block-title"},[s._v("注意")]),s._v(" "),a("p",[s._v("请确保你的 Node.js 版本 >= 8。")])])])}],!1,null,null,null);t.default=n.exports}}]); -------------------------------------------------------------------------------- /src/zh/algorithm/Charpter4.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar: auto 3 | sidebarDepth: 2 4 | --- 5 | 6 | # 第四章 编程基本功 7 | ## 4.1 字符类型统计器 8 | 请编写一个C程序,在终端用键盘输入字符串,以Ctrl+Z组合键表示输入完毕,统计输入的字符串中的空格符,制表符,换行符的个数,并显示统计的结果 9 | 10 | 11 | ## 4.2 计算字符的ASCII码 12 | 编写一个程序,在终端输入一个字符,输出它的ASCII码 13 | 14 | ## 4.3 嵌套if-slse语句的妙用 15 | 学校进行成绩分级管理,取消分数制,改为成绩分级评定。具体办法是:小于60分为E类;60分至70分(不含70分)为D类;70分至80分(不含)为C类;80分至90分(不含)为B类;90分以上为A类。设计一个程序,对输入的成绩进行等级划分 16 | 17 | ## 4.4 基于switch语句的译码器 18 | 给定一个成绩码表如下: 19 | |a|b|c| 20 | |-|--|--| 21 | |1|01|001| 22 | 又知有一个0/1字符串为:“001011101001011001”,编写一个C程序,按照给定的前缀码表为该字符串译码。 23 | 24 | ## 4.5 判断闰年 25 | 给定一个年份,判断该年是否是闰年。 26 | 27 | ## 4.6 指针变量作参数 28 | 编写一个函数inputArray,该函数被主函数调用,通过该函数实现向主函数中定义的数组输入数据 29 | 30 | ## 4.7 矩阵的转置运算 31 | ![矩阵转置](/study/algorithm/4.7.png) 32 | 33 | ## 4.8 矩阵的乘法运算 34 | ![矩阵乘法](/study/algorithm/4.8.png) 35 | 36 | ## 4.9 巧用位运算 37 | 用位运算操作实现两个整数的交换。例如x1=5,x2=10;交换后x1=10,x2=5。 38 | 39 | ## 4.10 文件的读写(忽略) 40 | 创建一个后缀名为txt的文件,并向该文件中写入一个字符串,保存起来。再打开该文件,读出文件中的内容。 41 | 42 | ## 4.11 计算文件的大小(忽略) 43 | 编写一个C程序,用来计算指定文件的大小。 44 | 45 | ## 4.12 记录程序的运行时间 46 | 任意编写一段程序,要求记录并输出该段程序执行的时间。 47 | 48 | ## 4.13 十进制/二进制转化器 49 | 编写一个程序,将输入的十进制数转化为二进制表示。例如:输入十进制数64,输出二进制数表示1000000 50 | 51 | ## 4.14 计打印特殊图案 52 | 在应用C语言开发程序时,有时为了程序运行界面的美观,需要在屏幕上用字符构成一些特殊的图案用以装饰。请设计一个C程序,实现在屏幕上输出一个类似于下面的图案。 53 | ![矩阵乘法](/study/algorithm/4.14.png) 54 | 55 | ## 4.15 打印杨辉三角 56 | 在屏幕上打印出一个6阶杨辉三角 57 | 58 | ## 4.16 复杂级数的前n项和 59 | ![矩阵乘法](/study/algorithm/4.16.png) 60 | 61 | ## 4.17 寻找矩阵中的"鞍点" 62 | 在一个矩阵中,可能会有这样的元素:它在该行中最大,而在该列中最小。我们把这样的元素称为“鞍点”。一个矩阵中也可能没有“鞍点”。任意输入一个5x5的矩阵,寻找该矩阵中的“鞍点”,并将它在矩阵中的位置(行,列)输出。 63 | 64 | ## 4.18 n阶勒让德多项式求解 65 | ![矩阵乘法](/study/algorithm/4.18.png) 66 | 测试:当n=5,x=1.6时,输出1.56 67 | 68 | ## 4.19 递归反向输出字符串 69 | 编写一个递归函数,实现将输入的任意长度的字符串反向输出的功能。例如输入字符串:ABCD,输出字符串:BCDA。 70 | 71 | ## 4.20 一年中的第几天 72 | 输入某年某月某日,判断这一天是这一年的第几天? -------------------------------------------------------------------------------- /docs/assets/js/72.38ef9238.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[72],{213:function(e,n,t){"use strict";t.r(n);var r=t(0),a=Object(r.a)({},function(){this.$createElement;this._self._c;return this._m(0)},[function(){var e=this,n=e.$createElement,t=e._self._c||n;return t("div",{staticClass:"content"},[t("h1",{attrs:{id:"vue路由"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#vue路由","aria-hidden":"true"}},[e._v("#")]),e._v(" Vue路由")]),e._v(" "),t("h4",{attrs:{id:"_1、路由-外置的-vue-router"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#_1、路由-外置的-vue-router","aria-hidden":"true"}},[e._v("#")]),e._v(" 1、路由(外置的) vue-router")]),e._v(" "),t("div",{staticClass:"language- extra-class"},[t("pre",{pre:!0,attrs:{class:"language-text"}},[t("code",[e._v("import VueRouter from 'vue-router';\nimport Index from './components/index.vue';\nimport List from './components/index.vue';\nimport Login from './components/index.vue';\n\nVue.use(VueRouter); // 注册\nlet router = new VueRouter({\n routes:[{ // 定义多个路由\n path:'/index', \n component:Index\n },{\n path:'/list',\n component:List\n },{\n path:'/login',\n component:Login\n },{\n path:'/music',\n component:Music,\n children:[{ // 封装子路由\n path:'/comd',\n component:Comd\n },{\n path:'/search',\n component:Search\n }]\n }]\n})\n\n\napp.vue // 入口文件\n\n")])])]),t("h4",{attrs:{id:"_2、路由跳转路径"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#_2、路由跳转路径","aria-hidden":"true"}},[e._v("#")]),e._v(" 2、路由跳转路径")]),e._v(" "),t("div",{staticClass:"language- extra-class"},[t("pre",{pre:!0,attrs:{class:"language-text"}},[t("code",[e._v('推荐\n\nrouter-link === a\nto === href\n')])])])])}],!1,null,null,null);n.default=a.exports}}]); -------------------------------------------------------------------------------- /lib/default-theme/SidebarGroup.vue: -------------------------------------------------------------------------------- 1 | 32 | 33 | 43 | 44 | 78 | -------------------------------------------------------------------------------- /src/zh/react/React生命周期.md: -------------------------------------------------------------------------------- 1 | # React生命周期 2 | #### 1、componentDidMount() // 组件挂载完成之后触发的生命周期 相当于vue的mounted 3 | ``` 4 | componentDidMount(){ 5 | setInterval(()=>{ 6 | // 修改state的唯一方法 7 | // @param 要修改的数据 8 | // @param 修改完成之后的回调函数 9 | this.setState({ 10 | index:this.state.index++ 11 | },()=>{ 12 | consloe.log(this.state.index) 13 | }) 14 | },1000) 15 | } 16 | 17 | ``` 18 | #### 2、componentWillMount() // 组件挂载之前 相当于vue的beforeMount 19 | #### 3、componentWillReceiveProps(nextProps) // 组件将要接收新的props vue没有 20 | 21 | ``` 22 | // 和props相关的唯一一个生命周期 23 | // 执行完成之后,this.props指向新的props 24 | componentWillReceiveProps(nextProps){ 25 | // 旧的props this.props 26 | // 新的props nextProps 27 | 28 | } 29 | 30 | 31 | ``` 32 | #### 4、shouldComponentUpdate(nextProps,nextState) // 通过返回值判断组件是否需要更新,用于react优化,vue没有 true更新,false不更新 33 | ``` 34 | shouldComponentUpdate(nextProps,nextState){ 35 | // 旧的props this.props 36 | // 新的props nextProps 37 | // 旧的State this.state 38 | // 新的state nextState 39 | // 返回值是Boolean 默认true 40 | } 41 | 42 | 43 | ``` 44 | #### 5、componentWillUpdate // 组件将要更新 相当于vue的beforeUpdate 45 | #### 6、componentDidUpdate // 组件更新完成 相当于vue的updated 46 | #### 7、componentWillUnmount() // 组件将要卸载 47 | #### 8、unmountComponentAtNode() // 卸载组件 48 | ``` 49 | ReactDom.unmountComponentAtNode(document.getElementById('root')) 50 | ``` 51 | #### 9、分为三个阶段 52 | 1. 实例化阶段 53 | 54 | ``` 55 | 首次使用一个组件类时会有getDefaultProps 56 | 对于组件类的所有后续应用没有getDefaultProps 57 | 1、getDefaultProps 58 | 2、getInitialState 59 | 3、componentWillMount 60 | 4、render 61 | 5、componentDidMount 62 | ``` 63 | 2. 更新阶段(存在期) 64 | 65 | 66 | ``` 67 | 1. componentWillReceiveProps 68 | 2. shouldComponentUpdate 69 | 3. componentWillUpdate 70 | 4. render 71 | 5. componentDidUpdate 72 | ``` 73 | 3. 销毁&清理期 74 | 75 | ``` 76 | componentWillUnmount 77 | ``` 78 | -------------------------------------------------------------------------------- /lib/app/root-mixins/updateMeta.js: -------------------------------------------------------------------------------- 1 | export default { 2 | created () { 3 | if (this.$ssrContext) { 4 | this.$ssrContext.title = this.$title 5 | this.$ssrContext.lang = this.$lang 6 | this.$ssrContext.description = this.$page.description || this.$description 7 | } 8 | }, 9 | 10 | mounted () { 11 | // update title / meta tags 12 | this.currentMetaTags = new Set() 13 | 14 | const updateMeta = () => { 15 | document.title = this.$title 16 | document.documentElement.lang = this.$lang 17 | const userMeta = this.$page.frontmatter.meta || [] 18 | const meta = userMeta.slice(0) 19 | const useGlobalDescription = userMeta.filter(m => m.name === 'description').length === 0 20 | 21 | // #665 Avoid duplicate description meta at runtime. 22 | if (useGlobalDescription) { 23 | meta.push({ name: 'description', content: this.$description }) 24 | } 25 | 26 | // Including description meta coming from SSR. 27 | const descriptionMetas = document.querySelectorAll('meta[name="description"]') 28 | if (descriptionMetas.length) { 29 | descriptionMetas.forEach(m => this.currentMetaTags.add(m)) 30 | } 31 | 32 | this.currentMetaTags = new Set(updateMetaTags(meta, this.currentMetaTags)) 33 | } 34 | this.$watch('$page', updateMeta) 35 | updateMeta() 36 | }, 37 | 38 | beforeDestroy () { 39 | updateMetaTags(null, this.currentMetaTags) 40 | } 41 | } 42 | 43 | function updateMetaTags (meta, current) { 44 | if (current) { 45 | [...current].forEach(c => { 46 | document.head.removeChild(c) 47 | }) 48 | } 49 | if (meta) { 50 | return meta.map(m => { 51 | const tag = document.createElement('meta') 52 | Object.keys(m).forEach(key => { 53 | tag.setAttribute(key, m[key]) 54 | }) 55 | document.head.appendChild(tag) 56 | return tag 57 | }) 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/zh/react/redux.md: -------------------------------------------------------------------------------- 1 | # Redux 2 | ##### 1、redux是什么? 3 | - 是一个框架 4 | - 跨组件通信 5 | #### 分四块内容 6 | 1. actionTypes 7 | 2. actions => {type, payload} 8 | 3. reducer 9 | 4. store 10 | 11 | #### redux三大原则 12 | 1. 单一数据源 13 | 2. State 是只读的 14 | 3. 使用纯函数来执行修改 15 | ##### 2、provider 16 | - 只有一个属性,是store 17 | - 顶层容器 18 | ##### 3、connect 19 | - 伪高阶函数 20 | - 4个参数 21 | 22 | ``` 23 | 1、把redux中state映射成的props传递到组件中去 // 获取state数据 24 | const mapStatetoProps = (state,ownProps)=>{ 25 | // state redux存储的数据 26 | // ownProps 组件调用时传过来的props 27 | // 返回一个对象 28 | } 29 | 30 | 2、把dispatch操作封装在当前函数里,传递到组件中 // 封装方法 31 | const mapDispatchtoProps = (dispatch, ownProps)=>{ 32 | // 返回一个对象 33 | return { 34 | fetchList:()=>{ 35 | axios.get('路径') 36 | .then(res=>{ 37 | // 触发dispatch 38 | dispatch({ 39 | type:'FETCH_LIST', 40 | payload:res.data 41 | }) 42 | }) 43 | } 44 | } 45 | 46 | } 47 | 48 | 3、合并props 49 | const mergeProps = (stateProps, dispatchProps, ownProps)=>{ 50 | // stateProps 是mapStateToProps的返回值 51 | // dispatchProps 是mapDispatchtoProps的返回值 52 | // ownProps 是调用时传入的props 53 | return {...stateProps, ...dispatchProps, ...ownProps} 54 | 55 | } 56 | 57 | 4、可选配置项 58 | const options = { 59 | pure:true 60 | // pure:表示state需要深拷贝才会响应 61 | // true 深拷贝(默认true 深拷贝) 62 | // false 浅拷贝深拷贝都可以 63 | } 64 | ``` 65 | ##### 4、reducer 66 | - 有两个参数:state action 67 | - 接收先前的 state 和 action,并返回新的 state 68 | ##### 5、深拷贝和浅拷贝 69 | - 深拷贝 ... 70 | - 浅拷贝 Object.assign() 71 | ##### 5、store 72 | - createStore接收两个参数 73 | > reducers 存储数据和修改数据 74 | 75 | > applyMiddleware 应用的中间件 76 | 77 | ##### 6、combineReducers // 合并 78 | 79 | ``` 80 | import {combineReducers} from 'redux'; 81 | import cart from './cart'; 82 | import my from './my'; 83 | 84 | export default combineReducers({ 85 | cart, 86 | my 87 | }) 88 | ``` 89 | -------------------------------------------------------------------------------- /docs/assets/js/45.d5a892d0.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[45],{169:function(t,e,s){"use strict";s.r(e);var n=s(0),a=Object(n.a)({},function(){this.$createElement;this._self._c;return this._m(0)},[function(){var t=this,e=t.$createElement,s=t._self._c||e;return s("div",{staticClass:"content"},[s("h1",{attrs:{id:"小程序组件"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#小程序组件","aria-hidden":"true"}},[t._v("#")]),t._v(" 小程序组件")]),t._v(" "),s("h5",{attrs:{id:"什么是组件"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#什么是组件","aria-hidden":"true"}},[t._v("#")]),t._v(" 什么是组件")]),t._v(" "),s("blockquote",[s("p",[t._v("组件就是将一个功能进行封装,组件是视图层的基本组成单元,有自己独特的功能")])]),t._v(" "),s("h5",{attrs:{id:"组件的规范"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#组件的规范","aria-hidden":"true"}},[t._v("#")]),t._v(" 组件的规范")]),t._v(" "),s("ol",[s("li",[t._v("结构")]),t._v(" "),s("li",[t._v("样式")]),t._v(" "),s("li",[t._v("逻辑")]),t._v(" "),s("li",[t._v("通信方式")]),t._v(" "),s("li",[t._v("生命周期")]),t._v(" "),s("li",[t._v("可组合(可以嵌套)")]),t._v(" "),s("li",[t._v("定义组件")]),t._v(" "),s("li",[t._v("调用组件(标签的形式)")])]),t._v(" "),s("h5",{attrs:{id:"组件的创建"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#组件的创建","aria-hidden":"true"}},[t._v("#")]),t._v(" 组件的创建")]),t._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[t._v("1.小程序中组件由4个文件组成,.json .wxmll .wxss .js\n2.创建组件实例需要通过Compoent(Object) 函数创建\n3.创建组件需要在组件的json文件中定义 component:true 字段指定为一个组件\n4.组件中的基础选项\n (1)Properties: 接受的数据\n (2)Data: 内部数据\n (3)Methods: 处理函数\n5.使用组件\n6.需要在对应的页面或者组件的json文件中定义 usingComponents: {} 选项\n usingComponets: {\n '名-称': '组件路径' \n }\n7.在页面中可以实用 <名-称/>\n8.名称中不能出现大写字母,规则就是(字母_-)\n9.组件的组合可以实用slot插槽来完成,和vue一样,只不过没有作用域插槽, 可以有命名插槽和默认插槽\n10.组件的通信可以通过props传递参数(父子), 自定义事件(子父)\n (1)父子 \n (2)子父 组件内部通过this.triggerEvent(‘test’, {detail:对象})\n")])])])])}],!1,null,null,null);e.default=a.exports}}]); -------------------------------------------------------------------------------- /docs/assets/js/75.fd9bf91f.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[75],{215:function(e,t,a){"use strict";a.r(t);var i=a(0),r=Object(i.a)({},function(){this.$createElement;this._self._c;return this._m(0)},[function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("div",{staticClass:"content"},[a("h1",{attrs:{id:"vue钩子"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#vue钩子","aria-hidden":"true"}},[e._v("#")]),e._v(" Vue钩子")]),e._v(" "),a("h4",{attrs:{id:"_1、钩子函数"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#_1、钩子函数","aria-hidden":"true"}},[e._v("#")]),e._v(" 1、钩子函数")]),e._v(" "),a("p",[e._v("指令定义函数提供了几个钩子函数(可选):")]),e._v(" "),a("ul",[a("li",[a("p",[e._v("bind: 只调用一次,指令第一次绑定到元素时调用,用这个钩子函数可以定义一个在绑定时执行一次的初始化动作。")])]),e._v(" "),a("li",[a("p",[e._v("inserted: 被绑定元素插入父节点时调用(父节点存在即可调用,不必存在于 document 中)。")])]),e._v(" "),a("li",[a("p",[e._v("update: 被绑定元素所在的模板更新时调用,而不论绑定值是否变化。通过比较更新前后的绑定值,可以忽略不必要的模板更新(详细的钩子函数参数见下)。")])]),e._v(" "),a("li",[a("p",[e._v("componentUpdated: 被绑定元素所在模板完成一次更新周期时调用。")])]),e._v(" "),a("li",[a("p",[e._v("unbind: 只调用一次, 指令与元素解绑时调用。")])])]),e._v(" "),a("h4",{attrs:{id:"_2、钩子函数参数"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#_2、钩子函数参数","aria-hidden":"true"}},[e._v("#")]),e._v(" 2、钩子函数参数")]),e._v(" "),a("p",[e._v("钩子函数的参数有:")]),e._v(" "),a("ol",[a("li",[e._v("el: 指令所绑定的元素,可以用来直接操作 DOM 。")]),e._v(" "),a("li",[e._v("binding: 一个对象,包含以下属性:")])]),e._v(" "),a("div",{staticClass:"language- extra-class"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v('name: 指令名,不包括 v- 前缀\nvalue: 指令的绑定值, 例如: v-my-directive="1 + 1", value 的值是 2。\noldValue: 指令绑定的前一个值,仅在 update 和 componentUpdated 钩子中可用。无论值是否改变都可用。\nexpression: 绑定值的表达式或变量名。 例如 v-my-directive="1 + 1" , expression 的值是 "1 + 1"。\narg: 传给指令的参数。例如 v-my-directive:foo, arg 的值是 "foo"。\nmodifiers: 一个包含修饰符的对象。 例如: v-my-directive.foo.bar, 修饰符对象 modifiers 的值是 { foo: true, bar: true }。\n')])])]),a("ol",{attrs:{start:"3"}},[a("li",[e._v("vnode: Vue 编译生成的虚拟节点。")]),e._v(" "),a("li",[e._v("oldVnode: 上一个虚拟节点,仅在 update 和 componentUpdated 钩子中可用。")])])])}],!1,null,null,null);t.default=r.exports}}]); -------------------------------------------------------------------------------- /docs/assets/js/70.6909a909.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[70],{217:function(t,a,e){"use strict";e.r(a);var r=e(0),v=Object(r.a)({},function(){this.$createElement;this._self._c;return this._m(0)},[function(){var t=this,a=t.$createElement,e=t._self._c||a;return e("div",{staticClass:"content"},[e("h1",{attrs:{id:"vue动画"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#vue动画","aria-hidden":"true"}},[t._v("#")]),t._v(" Vue动画")]),t._v(" "),e("h4",{attrs:{id:"_1、transition"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#_1、transition","aria-hidden":"true"}},[t._v("#")]),t._v(" 1、transition")]),t._v(" "),e("ol",[e("li",[t._v('name="" -> 手写')]),t._v(" "),e("li",[t._v("animate.css")]),t._v(" "),e("li",[t._v("velocity.js")])]),t._v(" "),e("h4",{attrs:{id:"_2、进入动画-从0-1"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#_2、进入动画-从0-1","aria-hidden":"true"}},[t._v("#")]),t._v(" 2、进入动画 从0-1")]),t._v(" "),e("ol",[e("li",[t._v("v-enter // 进入前")]),t._v(" "),e("li",[t._v("v-enter-active // 定义进入过渡生效时的状态")]),t._v(" "),e("li",[t._v("v-enter-to // 定义进入过渡结束时的状态")])]),t._v(" "),e("h4",{attrs:{id:"_3、离开动画-从1-0"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#_3、离开动画-从1-0","aria-hidden":"true"}},[t._v("#")]),t._v(" 3、离开动画 从1-0")]),t._v(" "),e("ol",[e("li",[t._v("v-leave // 离开前")]),t._v(" "),e("li",[t._v("v-leave-active // 离开中")]),t._v(" "),e("li",[t._v("v-leave-to // 离开后")])]),t._v(" "),e("h4",{attrs:{id:"_4、过渡持续时间"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#_4、过渡持续时间","aria-hidden":"true"}},[t._v("#")]),t._v(" 4、过渡持续时间")]),t._v(" "),e("ul",[e("li",[t._v(":duration='1000'")]),t._v(" "),e("li",[t._v(":duration='{enter:'1000',leave:'1000'}'")])]),t._v(" "),e("h4",{attrs:{id:"_5、javascript钩子"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#_5、javascript钩子","aria-hidden":"true"}},[t._v("#")]),t._v(" 5、JavaScript钩子")]),t._v(" "),e("div",{staticClass:"language- extra-class"},[e("pre",{pre:!0,attrs:{class:"language-text"}},[e("code",[t._v("v-on:before-enter \nv-on:enter \nv-on:after-enter \nv-on:enter-cancelled // 取消动画(删除)\n")])])])])}],!1,null,null,null);a.default=v.exports}}]); -------------------------------------------------------------------------------- /docs/assets/js/23.7c6d25d9.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[23],{193:function(t,a,e){"use strict";e.r(a);var r=e(0),i=Object(r.a)({},function(){this.$createElement;this._self._c;return this._m(0)},[function(){var t=this,a=t.$createElement,e=t._self._c||a;return e("div",{staticClass:"content"},[e("h1",{attrs:{id:"浏览器"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#浏览器","aria-hidden":"true"}},[t._v("#")]),t._v(" 浏览器")]),t._v(" "),e("h3",{attrs:{id:"浏览器历史"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#浏览器历史","aria-hidden":"true"}},[t._v("#")]),t._v(" 浏览器历史")]),t._v(" "),e("p",[t._v("最开始是3w浏览器,刚出来就很快死掉了,后来就出来了Mosaic浏览器,它是第一个普遍使用并且可以显示图片的网页浏览器。")]),t._v(" "),e("h3",{attrs:{id:"什么是浏览器"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#什么是浏览器","aria-hidden":"true"}},[t._v("#")]),t._v(" 什么是浏览器")]),t._v(" "),e("p",[t._v("浏览器分为两部分 ,一是shell部分(外壳),二是内核;用户可以看到和操作的部分是外壳,看不到的能够处理代码并且可以把代码完整显示出来的是内核部分,内核是最主要的一部分。")]),t._v(" "),e("h3",{attrs:{id:"内核"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#内核","aria-hidden":"true"}},[t._v("#")]),t._v(" 内核")]),t._v(" "),e("p",[t._v("内核大致分为两大部分,一是渲染引擎,二是js引擎;渲染引擎主要负责的是html和css一些基础语法的识别以及更高效的去绘图页面;js引擎越来越独立主要是负责JavaScript的")]),t._v(" "),e("h3",{attrs:{id:"主流浏览器机器内核-专业知识"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#主流浏览器机器内核-专业知识","aria-hidden":"true"}},[t._v("#")]),t._v(" 主流浏览器机器内核(专业知识)")]),t._v(" "),e("table",[e("thead",[e("tr",[e("th",[t._v("浏览器")]),t._v(" "),e("th",{staticStyle:{"text-align":"right"}},[t._v("内核")])])]),t._v(" "),e("tbody",[e("tr",[e("td",[t._v("IE")]),t._v(" "),e("td",{staticStyle:{"text-align":"right"}},[t._v("trident")])]),t._v(" "),e("tr",[e("td",[t._v("Chrome")]),t._v(" "),e("td",{staticStyle:{"text-align":"right"}},[t._v("webkit/blink")])]),t._v(" "),e("tr",[e("td",[t._v("firefox")]),t._v(" "),e("td",{staticStyle:{"text-align":"right"}},[t._v("Gecko")])]),t._v(" "),e("tr",[e("td",[t._v("opera")]),t._v(" "),e("td",{staticStyle:{"text-align":"right"}},[t._v("Presto")])]),t._v(" "),e("tr",[e("td",[t._v("safari")]),t._v(" "),e("td",{staticStyle:{"text-align":"right"}},[t._v("webkit")])])])])])}],!1,null,null,null);a.default=i.exports}}]); -------------------------------------------------------------------------------- /lib/default-theme/SWUpdatePopup.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 60 | 61 | 86 | -------------------------------------------------------------------------------- /test/markdown/link.spec.js: -------------------------------------------------------------------------------- 1 | import { Md } from './util' 2 | import link from '@/markdown/link.js' 3 | import { dataReturnable } from '@/markdown/index.js' 4 | 5 | const mdL = Md().use(link, { 6 | target: '_blank', 7 | rel: 'noopener noreferrer' 8 | }) 9 | 10 | dataReturnable(mdL) 11 | 12 | const internalLinkAsserts = { 13 | // START abosolute path usage 14 | '/': '/', 15 | 16 | '/foo/': '/foo/', 17 | '/foo/#hash': '/foo/#hash', 18 | 19 | '/foo/two.md': '/foo/two.html', 20 | '/foo/two.html': '/foo/two.html', 21 | // END abosolute path usage 22 | 23 | // START relative path usage 24 | 'README.md': './', 25 | './README.md': './', 26 | 27 | 'index.md': './', 28 | './index.md': './', 29 | 30 | 'one.md': './one.html', 31 | './one.md': './one.html', 32 | 33 | 'foo/README.md': './foo/', 34 | './foo/README.md': './foo/', 35 | 36 | 'foo/README.md#hash': './foo/#hash', 37 | './foo/README.md#hash': './foo/#hash', 38 | 39 | '../README.md': './../', 40 | '../README.md#hash': './../#hash', 41 | 42 | '../foo.md': './../foo.html', 43 | '../foo.md#hash': './../foo.html#hash', 44 | 45 | '../foo/one.md': './../foo/one.html', 46 | '../foo/one.md#hash': './../foo/one.html#hash' 47 | // END relative path usage 48 | } 49 | 50 | const externalLinks = [ 51 | '[vue](https://vuejs.org/)', 52 | '[vue](http://vuejs.org/)', 53 | '[some **link** with `code`](https://google.com)' // #496 54 | ] 55 | 56 | describe('link', () => { 57 | test('should convert internal links to router links correctly', () => { 58 | for (const before in internalLinkAsserts) { 59 | const input = `[${before}](${before})` 60 | const output = mdL.render(input) 61 | const after = getCompiledLink(output) 62 | expect(after).toBe(internalLinkAsserts[before]) 63 | } 64 | }) 65 | 66 | test('should render external links correctly', () => { 67 | for (const link of externalLinks) { 68 | const { html } = mdL.render(link) 69 | expect(html).toMatchSnapshot() 70 | } 71 | }) 72 | }) 73 | 74 | function getCompiledLink (output) { 75 | const { data: { routerLinks }} = output 76 | return routerLinks[0] 77 | } 78 | -------------------------------------------------------------------------------- /src/zh/interview/longhu.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 龙湖地产 3 | sidebar: auto 4 | sidebarDepth: 2 5 | --- 6 | # 龙湖地产 7 | ## 1. 块级和行内元素元素有哪些,它们有什么区别? 8 | 9 | ## 2. 为什么要少用Iframe? 10 | 11 | 12 | 13 | ## 3. 用css写出这样一个图形  (上下左右居中) 14 | 15 | 16 | 17 | ## 4. 写画如下代码的页面展示效果图,c盒子有position:relative 和没position值有什么区别? 18 | ```js 19 | 38 | 39 | 40 |
41 |
42 |
43 | 44 | ``` 45 | 46 | ## 5. call,apply和bind的区别列举使用方法 47 | 48 | 49 | ## 6. 写出下面代码的输入值 50 | ```js 51 | 6.1 (function(x){ 52 |     delete x; 53 | return x; 54 | })(1); 55 | 56 | 57 | 6.2 var y = 1, x = y = typeof x; 58 | console.log(x); 59 | 60 | 61 | 6.3 (function f(f){ 62 |     return typeof f(); 63 |   })(function(){ return 1; }); 64 | 65 | 66 | 6.4 !!typeof(null) 67 | ``` 68 | 69 | ## 7. 写出如下代码的运行结果 70 | ```js 71 | function Fun(){ 72 |       var printNum= function(){ 73 |           console.log(1); 74 |       } 75 |       return this; 76 |  } 77 |  Fun.printNum = function(){ 78 |       console.log(2); 79 |  } 80 |  Fun.prototype.printNum = function(){ 81 |      console.log(3); 82 |  } 83 |  var printNum = function(){ 84 |      console.log(4); 85 |  } 86 |  function printNum (){ 87 |      console.log(5); 88 |  } 89 |           90 |  Fun().printNum(); 91 |  printNum(); 92 |  Fun(); 93 |  printNum(); 94 |  new Fun().printNum(); 95 |  new new Fun().printNum(); 96 | ``` 97 | ## 8. var arr = [1,2,[3,4,[5]],6,[7,[8,9,[10,11,[12]]]]]请写一个方法把数组拍扁成普通数组。 98 | ```js 99 | arr.toString(); 100 | ``` 101 | 102 | ## 9. 写一写你常用和重要的es6知识点 103 | 104 | ## 10. 同步和异步的概念和区别。 105 | 106 | ## 11. 写出常见的http状态码及含义。 107 | 108 | ## 12. [数组去重的多种方法](https://m.jb51.net/show/118657) 109 | 110 | 111 | ## 13.url从输入地址栏到打开页面一系列操作描述一下 112 | 113 | ## 14.vue的相关知识 114 | -------------------------------------------------------------------------------- /src/zh/guide/README.md: -------------------------------------------------------------------------------- 1 | # 介绍 2 | 3 | VuePress 由两部分组成:一部分是支持用 Vue 开发主题的极简静态网站生成器,另一个部分是为书写技术文档而优化的默认主题。它的诞生初衷是为了支持 Vue 及其子项目的文档需求。 4 | 5 | 每一个由 VuePress 生成的页面都带有预渲染好的 HTML,也因此具有非常好的加载性能和搜索引擎优化(SEO)。同时,一旦页面被加载,Vue 将接管这些静态内容,并将其转换成一个完整的单页应用(SPA),其他的页面则会只在用户浏览到的时候才按需加载。 6 | 7 | ## 它是如何工作的? 8 | 9 | 事实上,一个 VuePress 网站是一个由 [Vue](http://vuejs.org/)、[Vue Router](https://github.com/vuejs/vue-router) 和 [webpack](http://webpack.js.org/) 驱动的单页应用。如果你以前使用过 Vue 的话,当你在开发一个自定义主题的时候,你会感受到非常熟悉的开发体验,你甚至可以使用 Vue DevTools 去调试你的自定义主题。 10 | 11 | 在构建时,我们会为应用创建一个服务端渲染(SSR)的版本,然后通过虚拟访问每一条路径来渲染对应的HTML。这种做法的灵感来源于 [Nuxt](https://nuxtjs.org/) 的 `nuxt generate` 命令,以及其他的一些项目,比如 [Gatsby](https://www.gatsbyjs.org/)。 12 | 13 | ## 特性 14 | 15 | - 为技术文档而优化的 [内置 Markdown 拓展](./markdown.md) 16 | - [在 Markdown 文件中使用 Vue 组件的能力](./using-vue.md) 17 | - [Vue 驱动的自定义主题系统](./custom-themes.md) 18 | - [自动生成 Service Worker](../config/README.md#serviceworker) 19 | - [Google Analytics 集成](../config/README.md#ga) 20 | - [基于 Git 的 “最后更新时间”](../default-theme-config/README.md#最后更新时间) 21 | - [多语言支持](./i18n.md) 22 | - 默认主题包含: 23 | - 响应式布局 24 | - [可选的主页](../default-theme-config/README.md#首页) 25 | - [简洁的开箱即用的标题搜索](../default-theme-config/README.md#内置搜索) 26 | - [Algolia 搜索](../default-theme-config/README.md#algolia-搜索) 27 | - 可自定义的[导航栏](../default-theme-config/README.md#导航栏) 和[侧边栏](../default-theme-config/README.md#侧边栏) 28 | - [自动生成的 GitHub 链接和页面的编辑链接](../default-theme-config/README.md#git-仓库和编辑链接) 29 | 30 | ## Todo 31 | 32 | VuePress 仍然处于开发中,这里有一些目前还不支持、但已经在计划中的特性: 33 | 34 | - 插件 35 | - 博客系统 36 | 37 | 我们欢迎你为 VuePress 的开发作出贡献。 38 | 39 | ## 为什么不是...? 40 | 41 | ### Nuxt 42 | 43 | VuePress 能做的事情,Nuxt 理论上确实能够胜任,但 Nuxt 是为构建应用程序而生的,而 VuePress 则专注在以内容为中心的静态网站上,同时提供了一些为技术文档定制的开箱即用的特性。 44 | 45 | ### studyify / Docute 46 | 47 | 这两个项目同样都是基于 Vue,然而它们都是完全的运行时驱动,因此对 SEO 不够友好。如果你并不关注 SEO,同时也不想安装大量依赖,它们仍然是非常好的选择! 48 | 49 | ### Hexo 50 | 51 | Hexo 一直驱动着 Vue 的文档 —— 事实上,在把我们的主站从 Hexo 迁移到 VuePress 之前,我们可能还有很长的路要走。Hexo 最大的问题在于他的主题系统太过于静态以及过度地依赖纯字符串,而我们十分希望能够好好地利用 Vue 来处理我们的布局和交互,同时,Hexo 的 Markdown 渲染的配置也不是最灵活的。 52 | 53 | ### GitBook 54 | 55 | 我们的子项目文档一直都在使用 GitBook。GitBook 最大的问题在于当文件很多时,每次编辑后的重新加载时间长得令人无法忍受。它的默认主题导航结构也比较有限制性,并且,主题系统也不是 Vue 驱动的。GitBook 背后的团队如今也更专注于将其打造为一个商业产品而不是开源工具。 56 | -------------------------------------------------------------------------------- /src/zh/standard/Project.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar: auto 3 | sidebarDepth: 2 4 | --- 5 | # 开发流程 6 | ## 图解 7 | ![项目流程](/study/project.jpg) 8 | ## 需求 9 | ### 评审 10 | 召集需求涉及到的UI、开发、产品、测试人员整理业务流程,同步信息,明确分工 11 | 明确需求目的,考虑当前需求设计是否可满足目的 12 | 整理流程中如果涉及的其他人员,则召集商讨 13 | 如需求设计上影响现有业务功能,应要求产品重新设计实现方案,然后重新评审 14 | ### 注意事项 15 | 业务流程同步:评审后重新梳理流程,存在疑问处及时找产品沟通 16 | 周边需求依赖:评审功能与依赖功能并行开发,由于前置需求未完成导致当前需求时间成本被压缩 17 | 埋点需求:提前与产品明确是否需要埋点 18 | 造数据:提前了解测试数据制造的困难程度,预估测试时间--->有些场景下的测试数据非常难造 19 | 并发量:后端机器是否能够承担新需求下的并发量,如果无法承担的话必须给出后续方案 20 | 自测:由于开发人员不予提供线上账号,因此自测也需要一名测试人员做线上回归测试 21 | 兼容范围:pc端需明确要兼容哪些浏览器,移动端需明确android与ios兼容版本以及哪些移动端浏览器 22 | ## 开发 23 | ### 评审 24 | #### 原型图评审 25 | 向产品明确原型图在应用中所处位置以及入口的显示条件,确认原型图的正确性 26 | #### 设计稿评审 27 | 观察线上应用设计风格与当前设计稿风格是否一致(色调,字号,行高,对齐方式)是否一致 28 | 观察设计稿中哪些部分需要切图 29 | 判断设计稿中组件是否开发过,避免重复造轮子 30 | #### 技术实现评审 31 | 如存在不易实现的功能,第一时间与产品沟通其他降级的实现方案 32 | #### 排期 33 | 找到相关开发(前端,后端,app)商讨需求实现技术细节,明确产出接口格式时间与接口联调时间 34 | #### 代码管理 35 | 为防止合并代码时过多的代码冲突问题,建议使用分支时遵循以下标准 36 | 每次push前先拉取线上分支代码 37 | 开发新功能或者修复bug时一定要基于线上代码分支创建新分支,每个分支只对应一个jira号或一个待修复的bug问题 38 | 分支名以f_(提交人)_(jira号)方式命名,对jira进行bug修复时使用f_(提交人)_fix_(bug内容)_(jira号) 39 | commit格式规则:每行message描述一个功能点,message格式为$(操作):$(描述),操作一般为add,del,upd分别代表新增、删除、更新三种操作 40 | ### 开发与调试 41 | 一般开发时不会从造轮子开始,项目中一般会有组件库供开发人员使用,但也会有一些老旧的项目中组件库版本较低,无法满足需求, 42 | 因此在开发前一定要对项目现有组件进行评估,确认是否需要重新开发组件,确保进度如期进行。 43 | 44 | #### pc端 45 | 推荐优雅降级方式开发,先chrome,firefox,然后再针对兼容性较差的如ie等进行兼容处理 46 | 47 | #### 移动端 48 | 移动端页面兼容性相较于pc端较好,但需真机调试,为方便调试移动页面,这里推荐使用spy-debugger来让pc端做代理,具体使用 49 | 请查阅github文档。 50 | 51 | ## 联调 52 | 和后端对接真实接口 53 | 54 | ## 自测 55 | 自测环节与环境数据关联很大,需要前后端共同完成,如果自测所需数据涉及范围较广,则需要找齐相关人员协助上线 56 | 57 | ## 提测 58 | 自测完成后开始进行真实环境测试 59 | 60 | ## bug反馈 61 | 62 | 63 | ## 部署上线 64 | 65 | 66 | 67 | ## 开发规范 68 | * 命名规范(文件命名,变量,函数,class, id) 驼峰, - _ 约定法 69 | * 目录规范(目录如何建立) 划分目录结构 约定法 70 | * 版本规范() 挑选稳定版本 记录版本号 如果版本升级,需要总结版本差异 71 | * 编码规范(注释,.... 语法) eslint语法 JSDoc注释 72 | * 适配规则(pc,移动) 分辨率调整 73 | * 接口规范(成功,失败,状态码,安全) 和后端约定 74 | 75 | ## 项目搭建 76 | * vue-cli脚手架搭建 -- 自定义项目用到的需求 77 | * 选择ui框架 78 | * 抽离公共逻辑,划分功能组件 79 | * 目录构建 80 | * 路由规划 81 | * ajax请求配置 82 | * mock生成 83 | * 架构文档 84 | * 方案整理(用到哪些技术,用到哪些特性) 85 | 86 | ## 代码管理 87 | * git & svn 88 | * 分支管理 89 | * 任务划分 90 | * 功能排期 91 | 92 | # 目的 93 | 整理和规划,提升开发效率 -------------------------------------------------------------------------------- /lib/prepare/index.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | const fs = require('fs-extra') 3 | const resolveOptions = require('./resolveOptions') 4 | const { genRoutesFile, genComponentRegistrationFile } = require('./codegen') 5 | const { writeTemp, writeEnhanceTemp } = require('./util') 6 | const logger = require('../util/logger') 7 | const chalk = require('chalk') 8 | 9 | module.exports = async function prepare (sourceDir) { 10 | // 1. load options 11 | const options = await resolveOptions(sourceDir) 12 | 13 | // 2. generate routes & user components registration code 14 | const routesCode = await genRoutesFile(options) 15 | const componentCode = await genComponentRegistrationFile(options) 16 | 17 | await writeTemp('routes.js', [ 18 | componentCode, 19 | routesCode 20 | ].join('\n')) 21 | 22 | // 3. generate siteData 23 | const dataCode = `export const siteData = ${JSON.stringify(options.siteData, null, 2)}` 24 | await writeTemp('siteData.js', dataCode) 25 | 26 | // 4. handle user override 27 | const overridePath = path.resolve(sourceDir, '.vuepress/override.styl').replace(/[\\]+/g, '/') 28 | const hasUserOverride = fs.existsSync(overridePath) 29 | await writeTemp('override.styl', hasUserOverride ? `@import(${JSON.stringify(overridePath)})` : ``) 30 | 31 | const stylePath = path.resolve(sourceDir, '.vuepress/style.styl').replace(/[\\]+/g, '/') 32 | const hasUserStyle = fs.existsSync(stylePath) 33 | await writeTemp('style.styl', hasUserStyle ? `@import(${JSON.stringify(stylePath)})` : ``) 34 | 35 | // Temporary tip, will be removed at next release. 36 | if (hasUserOverride && !hasUserStyle) { 37 | logger.tip( 38 | `${chalk.magenta('override.styl')} has been split into 2 APIs, we recommend you upgrade to continue.\n` + 39 | ` See: ${chalk.magenta('https://vuepress.vuejs.org/default-theme-config/#simple-css-override')}` 40 | ) 41 | } 42 | 43 | // 5. handle enhanceApp.js 44 | const enhanceAppPath = path.resolve(sourceDir, '.vuepress/enhanceApp.js') 45 | await writeEnhanceTemp('enhanceApp.js', enhanceAppPath) 46 | 47 | // 6. handle the theme enhanceApp.js 48 | await writeEnhanceTemp('themeEnhanceApp.js', options.themeEnhanceAppPath) 49 | 50 | return options 51 | } 52 | -------------------------------------------------------------------------------- /docs/assets/js/46.b2597f58.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[46],{168:function(e,t,l){"use strict";l.r(t);var s=l(0),r=Object(s.a)({},function(){this.$createElement;this._self._c;return this._m(0)},[function(){var e=this,t=e.$createElement,l=e._self._c||t;return l("div",{staticClass:"content"},[l("h1",{attrs:{id:"小程序组件化"}},[l("a",{staticClass:"header-anchor",attrs:{href:"#小程序组件化","aria-hidden":"true"}},[e._v("#")]),e._v(" 小程序组件化")]),e._v(" "),l("h5",{attrs:{id:"wxml节点信息api"}},[l("a",{staticClass:"header-anchor",attrs:{href:"#wxml节点信息api","aria-hidden":"true"}},[e._v("#")]),e._v(" wxml节点信息API")]),e._v(" "),l("ul",[l("li",[e._v("在小程序中使用"),l("strong",[e._v("wx.createSelectorQuery()"),l("strong",[e._v("获取到")]),e._v("SelectorQuery")]),e._v("对象,这个对象提供了对应的节点操作方法\n"),l("ul",[l("li",[l("strong",[e._v("in(this)")]),e._v(" 将节点选区范围指向当前组件,默认只会查找当期页面")]),e._v(" "),l("li",[l("strong",[e._v("select()")]),e._v(" 根据css选择器查询到匹配结果的第一个元素节点,返回的 NodesRef对象实例")]),e._v(" "),l("li",[l("strong",[e._v("selectAll()")]),e._v(" 和select一样只不过他可以匹配多个")]),e._v(" "),l("li",[l("strong",[e._v("selectViewport()")]),e._v(" 选择显示区域(页面),可用于获取显示区域的尺寸、滚动位置等信息,返回一个NodesRef对象实例。")]),e._v(" "),l("li",[l("strong",[e._v("exec()")]),e._v(" 执行所有的请求,请求结果按请求次序构成数组,在callback的第一个参数中返回。")])])])]),e._v(" "),l("h5",{attrs:{id:"nodesref对象"}},[l("a",{staticClass:"header-anchor",attrs:{href:"#nodesref对象","aria-hidden":"true"}},[e._v("#")]),e._v(" NodesRef对象")]),e._v(" "),l("p",[e._v("1、 "),l("strong",[e._v("boundingClientRect([callback])")])]),e._v(" "),l("blockquote",[l("p",[e._v("获取节点信息, 返回值相对于显示区域,以像素为单位。\n返回节点的信息有"),l("strong",[e._v("left、right、top、bottom、width、height")]),e._v(" 如果提供了callback回调函数,在执行selectQuery的exec方法后,节点信息会在callback中返回")])]),e._v(" "),l("p",[e._v("2、"),l("strong",[e._v("scrollOffset([callback])")])]),e._v(" "),l("blockquote",[l("p",[e._v("获取滚动位置信息,只针对与scroll-view组件以及viewport页面起作用,返回值是"),l("strong",[e._v("scrollLeft、scrollTop")]),e._v(",如果提供了callback回调函数,在执行selectQuery的exec方法后,节点信息会在callback中返回")])]),e._v(" "),l("p",[e._v("3、"),l("strong",[e._v("fields(Object, [callback])")])]),e._v(" "),l("blockquote",[l("p",[e._v("指定获取那些信息 (id, dataset, rect, size, scrollOffset , properties=[获取的常规属性名称(注:id class style 除外)], computedStyle=[获取的样式名称])")])])])}],!1,null,null,null);t.default=r.exports}}]); -------------------------------------------------------------------------------- /src/zh/vue/Vue组件.md: -------------------------------------------------------------------------------- 1 | # Vue组件 2 | #### 1、组件是什么? 3 | 1. 是vue.js最强大的功能之一 4 | 2. 可以扩展html元素,封装可重用的代码 5 | #### 2、注册全局组件 6 | 7 | ``` 8 | Vue.component('组件名称',引入的.vue文件) 9 | 10 | main.js 11 | import heads from 'src/heads'; 12 | Vue.component('heads',heads) 13 | // 然后在页面直接引用heads标签就可以了 14 | 15 | ``` 16 | #### 3、prop 17 | - 是父组件用来传递数据的一个自定义属性 18 | - 父组件的数据需要通过props把数据传给子组件,子组件需要显示地用props选项声明'prop'' 19 | 20 | ``` 21 | 参数: 22 | props:{ 23 | Child:{ 24 | type:Number, 25 | required:true // 默认值是false 26 | default:{ 27 | return{ 28 | msg:'hello!' 29 | } 30 | } 31 | } 32 | } 33 | ``` 34 | #### 4、自定义事件 35 | - $on(even) 监听事件 36 | - $emit(even) 触发事件 37 | #### 5、组件通讯 38 | 39 | ``` 40 | 1、同级目录 41 | 全局: window.Eventhub = new Vue(); 42 | 发送:methods:{ 43 | send(){ 44 | EventHub.$emit('HowAre',this.val) 45 | } 46 | } 47 | 接收:mounted(){ 48 | EventHub.$on('HowAre',res=>{ 49 | this.val = res 50 | }) 51 | } 52 | 2、父级向子级通讯(利用props) 53 | 父级: 54 | data(){ 55 | return{ 56 | tit:'加油加油 !' 57 | } 58 | } 59 | 子级: 60 | props:['tit'] 接收 61 | 62 | 3、子级向父级通讯(利用回调函数) 63 | 子级: 64 | this.$emit('solgan',this.val) 65 | 父级: 66 | 67 | methods:{ 68 | onSolgan(val){ 69 | this.solgan = val 70 | } 71 | } 72 | 73 | ``` 74 | 75 | #### 4、组件components/component 76 | 77 | 1. 局部(components) 78 | 79 | ``` 80 | 多个 81 | components:{ 82 | 组件名称:{ 83 | name: 84 | data(){ 85 | 86 | }, 87 | methods:{ 88 | 89 | }, 90 | beforeCreate:{ 91 | 92 | } 93 | template = html字符串 94 | // template有且只有一个子元素 95 | 96 | 97 | } 98 | } 99 | ``` 100 | 2. 全局(component) 101 | 102 | ``` 103 | Vue.component('组件名称',引入的.vue文件) 104 | ``` 105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /lib/markdown/index.js: -------------------------------------------------------------------------------- 1 | const highlight = require('./highlight') 2 | const highlightLines = require('./highlightLines') 3 | const preWrapper = require('./preWrapper') 4 | const lineNumbers = require('./lineNumbers') 5 | const component = require('./component') 6 | const hoistScriptStyle = require('./hoist') 7 | const convertRouterLink = require('./link') 8 | const containers = require('./containers') 9 | const snippet = require('./snippet') 10 | const emoji = require('markdown-it-emoji') 11 | const anchor = require('markdown-it-anchor') 12 | const toc = require('markdown-it-table-of-contents') 13 | const _slugify = require('./slugify') 14 | const { parseHeaders } = require('../util/parseHeaders') 15 | 16 | module.exports = ({ markdown = {}} = {}) => { 17 | // allow user config slugify 18 | const slugify = markdown.slugify || _slugify 19 | 20 | const md = require('markdown-it')({ 21 | html: true, 22 | highlight 23 | }) 24 | // custom plugins 25 | .use(component) 26 | .use(highlightLines) 27 | .use(preWrapper) 28 | .use(snippet) 29 | .use(convertRouterLink, Object.assign({ 30 | target: '_blank', 31 | rel: 'noopener noreferrer' 32 | }, markdown.externalLinks)) 33 | .use(hoistScriptStyle) 34 | .use(containers) 35 | 36 | // 3rd party plugins 37 | .use(emoji) 38 | .use(anchor, Object.assign({ 39 | slugify, 40 | permalink: true, 41 | permalinkBefore: true, 42 | permalinkSymbol: '#' 43 | }, markdown.anchor)) 44 | .use(toc, Object.assign({ 45 | slugify, 46 | includeLevel: [2, 3], 47 | format: parseHeaders 48 | }, markdown.toc)) 49 | 50 | // apply user config 51 | if (markdown.config) { 52 | markdown.config(md) 53 | } 54 | 55 | if (markdown.lineNumbers) { 56 | md.use(lineNumbers) 57 | } 58 | 59 | module.exports.dataReturnable(md) 60 | 61 | // expose slugify 62 | md.slugify = slugify 63 | 64 | return md 65 | } 66 | 67 | module.exports.dataReturnable = function dataReturnable (md) { 68 | // override render to allow custom plugins return data 69 | const render = md.render 70 | md.render = (...args) => { 71 | md.__data = {} 72 | const html = render.call(md, ...args) 73 | return { 74 | html, 75 | data: md.__data 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /lib/util/parseHeaders.js: -------------------------------------------------------------------------------- 1 | // Since VuePress needs to extract the header from the markdown source 2 | // file and display it in the sidebar or title (#238), this file simply 3 | // removes some unnecessary elements to make header displays well at 4 | // sidebar or title. 5 | // 6 | // But header's parsing in the markdown content is done by the markdown 7 | // loader based on markdown-it. markdown-it parser will will always keep 8 | // HTML in headers, so in VuePress, after being parsed by the markdiwn 9 | // loader, the raw HTML in headers will finally be parsed by Vue-loader. 10 | // so that we can write HTML/Vue in the header. One exception is the HTML 11 | // wrapped by (markdown token: '`') tag. 12 | 13 | const { compose } = require('./shared') 14 | 15 | const parseEmojis = str => { 16 | const emojiData = require('markdown-it-emoji/lib/data/full.json') 17 | return String(str).replace(/:(.+?):/g, (placeholder, key) => emojiData[key] || placeholder) 18 | } 19 | 20 | const unescapeHtml = html => String(html) 21 | .replace(/"/g, '"') 22 | .replace(/'/g, '\'') 23 | .replace(/:/g, ':') 24 | .replace(/</g, '<') 25 | .replace(/>/g, '>') 26 | 27 | const removeMarkdownTokens = str => String(str) 28 | .replace(/\[(.*)\]\(.*\)/, '$1') // []() 29 | .replace(/(`|\*{1,3}|_)(.*?[^\\])\1/g, '$2') // `{t}` | *{t}* | **{t}** | ***{t}*** | _{t}_ 30 | .replace(/(\\)(\*|_|`)/g, '$2') // remove escape char '\' 31 | 32 | const trim = str => str.trim() 33 | 34 | // This method remove the raw HTML but reserve the HTML wrapped by ``. 35 | // e.g. 36 | // Input: " b", Output: "b" 37 | // Input: "`` b", Output: "`` b" 38 | exports.removeNonCodeWrappedHTML = (str) => { 39 | return String(str).replace(/(^|[^><`])<.*>([^><`]|$)/g, '$1$2') 40 | } 41 | 42 | // Unescape html, parse emojis and remove some md tokens. 43 | exports.parseHeaders = compose( 44 | unescapeHtml, 45 | parseEmojis, 46 | removeMarkdownTokens, 47 | trim 48 | ) 49 | 50 | // Also clean the html that isn't wrapped by code. 51 | // Because we want to support using VUE components in headers. 52 | // e.g. https://vuepress.vuejs.org/guide/using-vue.html#badge 53 | exports.deeplyParseHeaders = compose( 54 | exports.removeNonCodeWrappedHTML, 55 | exports.parseHeaders, 56 | ) 57 | -------------------------------------------------------------------------------- /lib/webpack/createClientConfig.js: -------------------------------------------------------------------------------- 1 | module.exports = function createClientConfig (options, cliOptions) { 2 | const path = require('path') 3 | const WebpackBar = require('webpackbar') 4 | const createBaseConfig = require('./createBaseConfig') 5 | 6 | const config = createBaseConfig(options, cliOptions) 7 | 8 | config 9 | .entry('app') 10 | .add(path.resolve(__dirname, '../app/clientEntry.js')) 11 | 12 | config.node 13 | .merge({ 14 | // prevent webpack from injecting useless setImmediate polyfill because Vue 15 | // source contains it (although only uses it if it's native). 16 | setImmediate: false, 17 | global: false, 18 | process: false, 19 | // prevent webpack from injecting mocks to Node native modules 20 | // that does not make sense for the client 21 | dgram: 'empty', 22 | fs: 'empty', 23 | net: 'empty', 24 | tls: 'empty', 25 | child_process: 'empty' 26 | }) 27 | 28 | // generate client manifest only during build 29 | if (process.env.NODE_ENV === 'production') { 30 | // This is a temp build of vue-server-renderer/client-plugin. 31 | // TODO Switch back to original after problems are resolved. 32 | // Fixes two things: 33 | // 1. Include CSS in preload files 34 | // 2. filter out useless styles.xxxxx.js chunk from mini-css-extract-plugin 35 | // https://github.com/webpack-contrib/mini-css-extract-plugin/issues/85 36 | config 37 | .plugin('ssr-client') 38 | .use(require('./ClientPlugin'), [{ 39 | filename: 'manifest/client.json' 40 | }]) 41 | 42 | config 43 | .plugin('optimize-css') 44 | .use(require('optimize-css-assets-webpack-plugin'), [{ 45 | canPrint: false, 46 | cssProcessorOptions: { 47 | safe: true, 48 | autoprefixer: { disable: true }, 49 | mergeLonghand: false 50 | } 51 | }]) 52 | } 53 | 54 | if (!cliOptions.debug) { 55 | config 56 | .plugin('bar') 57 | .use(WebpackBar, [{ 58 | name: 'Client', 59 | color: '#41b883', 60 | compiledIn: false 61 | }]) 62 | } 63 | 64 | if (options.siteConfig.chainWebpack) { 65 | options.siteConfig.chainWebpack(config, false /* isServer */) 66 | } 67 | 68 | return config 69 | } 70 | -------------------------------------------------------------------------------- /lib/util/index.js: -------------------------------------------------------------------------------- 1 | const { deeplyParseHeaders } = require('./parseHeaders') 2 | 3 | exports.normalizeHeadTag = function (tag) { 4 | if (typeof tag === 'string') { 5 | tag = [tag] 6 | } 7 | const tagName = tag[0] 8 | return { 9 | tagName, 10 | attributes: tag[1] || {}, 11 | innerHTML: tag[2] || '', 12 | closeTag: !(tagName === 'meta' || tagName === 'link') 13 | } 14 | } 15 | 16 | exports.applyUserWebpackConfig = function (userConfig, config, isServer) { 17 | const merge = require('webpack-merge') 18 | if (typeof userConfig === 'object') { 19 | return merge(config, userConfig) 20 | } 21 | if (typeof userConfig === 'function') { 22 | const res = userConfig(config, isServer) 23 | if (res && typeof res === 'object') { 24 | return merge(config, res) 25 | } 26 | } 27 | return config 28 | } 29 | 30 | exports.inferTitle = function (frontmatter) { 31 | if (frontmatter.data.home) { 32 | return 'Home' 33 | } 34 | if (frontmatter.data.title) { 35 | return deeplyParseHeaders(frontmatter.data.title) 36 | } 37 | const match = frontmatter.content.trim().match(/^#+\s+(.*)/) 38 | if (match) { 39 | return deeplyParseHeaders(match[1]) 40 | } 41 | } 42 | 43 | exports.parseFrontmatter = function (content) { 44 | const matter = require('gray-matter') 45 | const toml = require('toml') 46 | 47 | return matter(content, { 48 | excerpt_separator: '', 49 | engines: { 50 | toml: toml.parse.bind(toml), 51 | excerpt: false 52 | } 53 | }) 54 | } 55 | 56 | const LRU = require('lru-cache') 57 | const cache = LRU({ max: 1000 }) 58 | 59 | exports.extractHeaders = function (content, include = [], md) { 60 | const key = content + include.join(',') 61 | const hit = cache.get(key) 62 | if (hit) { 63 | return hit 64 | } 65 | 66 | const tokens = md.parse(content, {}) 67 | 68 | const res = [] 69 | tokens.forEach((t, i) => { 70 | if (t.type === 'heading_open' && include.includes(t.tag)) { 71 | const title = tokens[i + 1].content 72 | const slug = t.attrs.find(([name]) => name === 'id')[1] 73 | res.push({ 74 | level: parseInt(t.tag.slice(1), 10), 75 | title: deeplyParseHeaders(title), 76 | slug: slug || md.slugify(title) 77 | }) 78 | } 79 | }) 80 | 81 | cache.set(key, res) 82 | return res 83 | } 84 | -------------------------------------------------------------------------------- /lib/prepare/codegen.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | const { fileToComponentName, resolveComponents } = require('./util') 3 | 4 | exports.genRoutesFile = async function ({ 5 | siteData: { pages }, 6 | sourceDir, 7 | pageFiles 8 | }) { 9 | function genRoute ({ path: pagePath, key: componentName }, index) { 10 | const file = pageFiles[index] 11 | const filePath = path.resolve(sourceDir, file) 12 | let code = ` 13 | { 14 | name: ${JSON.stringify(componentName)}, 15 | path: ${JSON.stringify(pagePath)}, 16 | component: ThemeLayout, 17 | beforeEnter: (to, from, next) => { 18 | import(${JSON.stringify(filePath)}).then(comp => { 19 | Vue.component(${JSON.stringify(componentName)}, comp.default) 20 | next() 21 | }) 22 | } 23 | }` 24 | 25 | const dncodedPath = decodeURIComponent(pagePath) 26 | if (dncodedPath !== pagePath) { 27 | code += `, 28 | { 29 | path: ${JSON.stringify(dncodedPath)}, 30 | redirect: ${JSON.stringify(pagePath)} 31 | }` 32 | } 33 | 34 | if (/\/$/.test(pagePath)) { 35 | code += `, 36 | { 37 | path: ${JSON.stringify(pagePath + 'index.html')}, 38 | redirect: ${JSON.stringify(pagePath)} 39 | }` 40 | } 41 | 42 | return code 43 | } 44 | 45 | const notFoundRoute = `, 46 | { 47 | path: '*', 48 | component: ThemeNotFound 49 | }` 50 | 51 | return ( 52 | `import ThemeLayout from '@themeLayout'\n` + 53 | `import ThemeNotFound from '@themeNotFound'\n` + 54 | `import { injectMixins } from '@app/util'\n` + 55 | `import rootMixins from '@app/root-mixins'\n\n` + 56 | `injectMixins(ThemeLayout, rootMixins)\n` + 57 | `injectMixins(ThemeNotFound, rootMixins)\n\n` + 58 | `export const routes = [${pages.map(genRoute).join(',')}${notFoundRoute}\n]` 59 | ) 60 | } 61 | 62 | exports.genComponentRegistrationFile = async function ({ sourceDir }) { 63 | function genImport (file) { 64 | const name = fileToComponentName(file) 65 | const baseDir = path.resolve(sourceDir, '.vuepress/components') 66 | const absolutePath = path.resolve(baseDir, file) 67 | const code = `Vue.component(${JSON.stringify(name)}, () => import(${JSON.stringify(absolutePath)}))` 68 | return code 69 | } 70 | 71 | const components = (await resolveComponents(sourceDir)) || [] 72 | return `import Vue from 'vue'\n` + components.map(genImport).join('\n') 73 | } 74 | 75 | -------------------------------------------------------------------------------- /docs/assets/js/43.8b6224f6.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[43],{171:function(t,a,e){"use strict";e.r(a);var r=e(0),s=Object(r.a)({},function(){this.$createElement;this._self._c;return this._m(0)},[function(){var t=this,a=t.$createElement,e=t._self._c||a;return e("div",{staticClass:"content"},[e("h1",{attrs:{id:"组件通信"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#组件通信","aria-hidden":"true"}},[t._v("#")]),t._v(" 组件通信")]),t._v(" "),e("h5",{attrs:{id:"emit"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#emit","aria-hidden":"true"}},[t._v("#")]),t._v(" $emit")]),t._v(" "),e("blockquote",[e("p",[t._v("子向父通信")])]),t._v(" "),e("h5",{attrs:{id:"broadcast"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#broadcast","aria-hidden":"true"}},[t._v("#")]),t._v(" $broadcast")]),t._v(" "),e("blockquote",[e("p",[t._v("父向子通信")])]),t._v(" "),e("h5",{attrs:{id:"父子通信:父组件传递数据给子组件"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#父子通信:父组件传递数据给子组件","aria-hidden":"true"}},[t._v("#")]),t._v(" 父子通信:父组件传递数据给子组件")]),t._v(" "),e("p",[e("strong",[t._v("1、通过props传值")])]),t._v(" "),e("ol",[e("li",[t._v("如果需要传递动态属性值需要添加.sync修饰符")]),t._v(" "),e("li",[t._v("如果要在子组件中修改父组件数据需要在接受的时候添加 twoWay: true")]),t._v(" "),e("li",[t._v("如果需要数据双向绑定需要(.sync 和 twoWay 同时)")])]),t._v(" "),e("p",[e("strong",[t._v("2、实用$broadcast将数据广播到所有子组件中")])]),t._v(" "),e("h5",{attrs:{id:"子父通信:子组件传递数据给父组件"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#子父通信:子组件传递数据给父组件","aria-hidden":"true"}},[t._v("#")]),t._v(" 子父通信:子组件传递数据给父组件")]),t._v(" "),e("ol",[e("li",[t._v("在父组件中events中定义事件,在子组件$emit触发 (推荐)")]),t._v(" "),e("li",[t._v("在父组件methods中添加方法,在子组件中this.$invoke('../', '函数名称')")]),t._v(" "),e("li",[t._v("在子组件中通过this.$parent获取到父组件实例,调用父组件回调函数给父组件发送数据")])]),t._v(" "),e("h5",{attrs:{id:"同级:a、b两个同级组件的数据发送"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#同级:a、b两个同级组件的数据发送","aria-hidden":"true"}},[t._v("#")]),t._v(" 同级:A、B两个同级组件的数据发送")]),t._v(" "),e("ol",[e("li",[t._v("在A组件中通过this.$invoke('../B', '函数名称') 调用B组件中的回调函数传递数据")]),t._v(" "),e("li",[t._v("将数据发送到父组件,父组件在传递给另一个子组件(代理方式)")]),t._v(" "),e("li",[t._v("自己封装一个发布订阅器(eventbus)")])]),t._v(" "),e("h5",{attrs:{id:"跨级:"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#跨级:","aria-hidden":"true"}},[t._v("#")]),t._v(" 跨级:")]),t._v(" "),e("ol",[e("li",[t._v("逐层传递")]),t._v(" "),e("li",[t._v("this.$invoke('组件路径', '函数名称')")])]),t._v(" "),e("p",[e("strong",[t._v("使用redux可以做所有的数据管理")])])])}],!1,null,null,null);a.default=s.exports}}]); -------------------------------------------------------------------------------- /src/guide/README.md: -------------------------------------------------------------------------------- 1 | # 介绍 2 | 3 | 4 | 5 | VuePress 由两部分组成:一个以 Vue 驱动的主题系统的简约静态网站生成工具,和一个为编写技术文档而优化的默认主题。它是为了支持 Vue 子项目的文档需求而创建的。 6 | 7 | 由 VuePress 生成的每个页面,都具有相应的预渲染静态 HTML,它们能提供出色的加载性能,并且对 SEO 友好。然而,页面加载之后,Vue 就会将这些静态内容,接管为完整的单页面应用程序(SPA)。当用户在浏览站点时,可以按需加载其他页面。 8 | 9 | ## 运行原理(how it works) 10 | 11 | VuePress 网站实际上是由 [Vue](http://vuejs.org/), [Vue Router](https://github.com/vuejs/vue-router) 和 [webpack](http://webpack.js.org/) 驱动的单页面应用程序。如果你以前使用过 Vue,那么在编写或开发自定义主题时(甚至可以使用 Vue DevTools 来调试你的自定义主题!),你会融入到熟悉的开发体验中! 12 | 13 | 在构建过程中,我们会创建应用程序的服务器渲染版本,并且实际上是通过访问每个路由,来渲染相应的 HTML。这种方式受到 [Nuxt](https://nuxtjs.org/) 的 `nuxt generate` 命令以及 [Gatsby](https://www.gatsbyjs.org/) 等其他项目的启发。 14 | 15 | 每个 markdown 文件都使用 [markdown-it](https://github.com/markdown-it/markdown-it) 编译为 HTML,然后作为 Vue 组件的模板进行处理。这允许你直接在 markdown 文件中使用 Vue,在需要嵌入动态内容时,这种使用方式非常有用。 16 | 17 | ## 特性(features) 18 | 19 | - [内置 markdown 扩展](./markdown.md),针对技术文档进行了优化 20 | - [能够利用内嵌在 markdown 文件中的 Vue 代码](./using-vue.md) 21 | - [以 Vue 驱动的自定义主题系统](./custom-themes.md) 22 | - [自动生成 Service Worker](../config/README.md#serviceworker) 23 | - [Google Analytics 集成](../config/README.md#ga) 24 | - [基于 Git 的"最近更新"](../default-theme-config/README.md#最近更新) 25 | - [多语言支持](./i18n.md) 26 | - 一个默认主题包括: 27 | - 响应式布局 28 | - [可选的主页](../default-theme-config/README.md#主页-homepage) 29 | - [简单、开箱即用、基于标题的搜索功能](../default-theme-config/README.md#内置搜索-built-in-search) 30 | - [Algolia 搜索](../default-theme-config/README.md#algolia-search) 31 | - 可定制的[导航栏](../default-theme-config/README.md#导航栏-navbar)和[侧边栏](../default-theme-config/README.md#侧边栏-sidebar) 32 | - [自动生成的 GitHub 链接和页面编辑链接](../default-theme-config/README.md#git-仓库和编辑链接) 33 | 34 | ## 待实现特性(todo) 35 | 36 | VuePress 的开发仍在进行中。有几件目前不支持,但计划做的功能: 37 | 38 | - 插件支持 39 | - 博客支持 40 | 41 | 欢迎贡献! 42 | 43 | ## 为什么不使用下面这些工具? 44 | 45 | ### Nuxt 46 | 47 | VuePress 能做的事情,Nuxt 也同样能够实现,但是,它是为构建应用程序而设计的。而 VuePress 专注于以内容为中心的静态网站,并且为开箱即用的技术文档,提供量身定制的功能。 48 | 49 | ### Docsify / Docute 50 | 51 | 二者都是伟大的项目,也都是以 Vue 驱动。但它们完全是运行时驱动(runtime-driven)的项目,因此不适合 SEO 优化。如果你不关心 SEO 优化,也不想因为安装依赖而扰乱心神,这些仍然是不错的选择。 52 | 53 | ### Hexo 54 | 55 | Hexo 一直在为 Vue 文档提供服务 - 事实上,离我们的主站完全迁移到 VuePress,可能还要经过一段时间。其中最大的问题是,它的主题系统是非常静态和基于字符串的 - 我们确实需要利用 Vue 来实现布局和交互。此外,无法对 Hexo 的 markdown 渲染,进行极其灵活的配置。 56 | 57 | ### GitBook 58 | 59 | 我们大部分的子项目文档中已经使用了 GitBook。GitBook 的主要问题是有大量文件时,它的开发重载性能简直令人无法容忍。它的默认主题也只有一个非常有限的导航结构,并且主题系统也不是基于 Vue 的。GitBook 背后的团队也更注重将其打造为一个商业产品,而不是开源工具。 60 | -------------------------------------------------------------------------------- /src/zh/vue/vuex.md: -------------------------------------------------------------------------------- 1 | # Vuex 2 | ##### 1、什么是vuex? 3 | - 每一个 Vuex 应用的核心就是 store(仓库)。“store”基本上就是一个容器,它包含着你的应用中大部分的状态 (state)。 4 | 5 | ##### 2、初始化vuex 6 | (1)下载vuex 7 | 8 | ``` 9 | cnpm i vuex -D 10 | ``` 11 | 12 | 13 | (2)建一个store文件夹(store/index.js) 14 | 15 | ``` 16 | // 初始化vuex 17 | 18 | import Vue from 'vue'; 19 | import Vuex from 'vuex'; 20 | 21 | // 引入module 22 | import app from './module/app'; 23 | 24 | Vue.use(Vuex); 25 | 26 | // 生成一个vuex实例 27 | export default new Vuex.Store({ 28 | modules: { 29 | app 30 | } 31 | }) 32 | ``` 33 | (3)在store文件夹里建一个module文件夹用来存放数据(store/module/app.js) 34 | 35 | ``` 36 | // 存放数据的地方 37 | const state = { 38 | num: 100 39 | } 40 | 41 | // 派生数据(很少用) 42 | const getters = { 43 | doubleNum(state){ 44 | return state.num*2 45 | } 46 | } 47 | 48 | // 同步改变 49 | const mutations = { 50 | changeNum(state, payload){ 51 | state.num = payload; 52 | } 53 | } 54 | 55 | // 异步改变 56 | const actions = { 57 | 58 | 59 | 60 | changeNumAsync({commit}, payload){ 61 | commit('changeNum', payload) 62 | } 63 | } 64 | 65 | export default { 66 | // 命名空间 67 | namespaced: true, // 配合module使用 68 | state, 69 | actions, 70 | getters, 71 | mutations 72 | } 73 | ``` 74 | (4)在main.js里面引入store 75 | 76 | ``` 77 | import Vue from 'vue' 78 | import App from './App.vue' 79 | 80 | import store from './store' 81 | 82 | new Vue({ 83 | el: '#app', 84 | store, 85 | render: h => h(App) 86 | }) 87 | 88 | ``` 89 | (5)在页面中使用 90 | 91 | ``` 92 | 99 | 122 | 123 | ``` 124 | 125 | -------------------------------------------------------------------------------- /src/zh/guide/i18n.md: -------------------------------------------------------------------------------- 1 | # 多语言支持 2 | 3 | ## 站点多语言配置 4 | 5 | 要启用 VuePress 的多语言支持,首先需要使用如下的文件结构: 6 | 7 | ``` 8 | study 9 | ├─ README.md 10 | ├─ foo.md 11 | ├─ nested 12 | │  └─ README.md 13 | └─ zh 14 | ├─ README.md 15 | ├─ foo.md 16 | └─ nested 17 |    └─ README.md 18 | ``` 19 | 20 | 然后,在 `.vuepress/config.js` 中提供 `locales` 选项: 21 | 22 | ``` js 23 | module.exports = { 24 | locales: { 25 | // 键名是该语言所属的子路径 26 | // 作为特例,默认语言可以使用 '/' 作为其路径。 27 | '/': { 28 | lang: 'en-US', // 将会被设置为 的 lang 属性 29 | title: 'VuePress', 30 | description: 'Vue-powered Static Site Generator' 31 | }, 32 | '/zh/': { 33 | lang: 'zh-CN', 34 | title: 'VuePress', 35 | description: 'Vue 驱动的静态网站生成器' 36 | } 37 | } 38 | } 39 | ``` 40 | 41 | 如果一个语言没有声明 `title` 或者 `description`,VuePress 将会尝试使用配置顶层的对应值。如果每个语言都声明了 `title` 和 `description`,则顶层的这两个值可以被省略。 42 | 43 | ## 默认主题多语言配置 44 | 45 | 默认主题也内置了多语言支持,可以通过 `themeConfig.locales` 来配置。该选项接受同样的 `{ path: config }` 格式的值。每个语言除了可以配置一些站点中用到的文字之外,还可以拥有自己的 [导航栏](../default-theme-config/README.md#导航栏) 和 [侧边栏](../default-theme-config/README.md#侧边栏) 配置: 46 | 47 | ``` js 48 | module.exports = { 49 | locales: { /* ... */ }, 50 | themeConfig: { 51 | locales: { 52 | '/': { 53 | selectText: 'Languages', 54 | label: 'English', 55 | editLinkText: 'Edit this page on GitHub', 56 | serviceWorker: { 57 | updatePopup: { 58 | message: "New content is available.", 59 | buttonText: "Refresh" 60 | } 61 | }, 62 | algolia: {}, 63 | nav: [ 64 | { text: 'Nested', link: '/nested/' } 65 | ], 66 | sidebar: { 67 | '/': [/* ... */], 68 | '/nested/': [/* ... */] 69 | } 70 | }, 71 | '/zh/': { 72 | // 多语言下拉菜单的标题 73 | selectText: '选择语言', 74 | // 该语言在下拉菜单中的标签 75 | label: '简体中文', 76 | // 编辑链接文字 77 | editLinkText: '在 GitHub 上编辑此页', 78 | // Service Worker 的配置 79 | serviceWorker: { 80 | updatePopup: { 81 | message: "发现新内容可用.", 82 | buttonText: "刷新" 83 | } 84 | }, 85 | // 当前 locale 的 algolia studyearch 选项 86 | algolia: {}, 87 | nav: [ 88 | { text: '嵌套', link: '/zh/nested/' } 89 | ], 90 | sidebar: { 91 | '/zh/': [/* ... */], 92 | '/zh/nested/': [/* ... */] 93 | } 94 | } 95 | } 96 | } 97 | } 98 | ``` 99 | -------------------------------------------------------------------------------- /docs/assets/js/39.84216f96.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[39],{175:function(v,_,e){"use strict";e.r(_);var t=e(0),i=Object(t.a)({},function(){this.$createElement;this._self._c;return this._m(0)},[function(){var v=this,_=v.$createElement,e=v._self._c||_;return e("div",{staticClass:"content"},[e("h1",{attrs:{id:"面试必备知识点"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#面试必备知识点","aria-hidden":"true"}},[v._v("#")]),v._v(" 面试必备知识点")]),v._v(" "),e("h2",{attrs:{id:"css"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#css","aria-hidden":"true"}},[v._v("#")]),v._v(" CSS")]),v._v(" "),e("ul",[e("li",[v._v("盒模型")]),v._v(" "),e("li",[v._v("CSS的单位和应用场景及Rem的设置")]),v._v(" "),e("li",[v._v("定位,回流与重绘")]),v._v(" "),e("li",[v._v("IFC、BFC与清除浮动")]),v._v(" "),e("li",[v._v("兼容处理")])]),v._v(" "),e("h2",{attrs:{id:"原生js"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#原生js","aria-hidden":"true"}},[v._v("#")]),v._v(" 原生JS")]),v._v(" "),e("ul",[e("li",[v._v("变量提升配合作用域链")]),v._v(" "),e("li",[v._v("原型链")]),v._v(" "),e("li",[v._v("继承")]),v._v(" "),e("li",[v._v("闭包")]),v._v(" "),e("li",[v._v("new与面向对象")]),v._v(" "),e("li",[v._v("event loop")]),v._v(" "),e("li",[v._v("event delegation/proxy")]),v._v(" "),e("li",[v._v("节流与防动")]),v._v(" "),e("li",[v._v("Promise原理")]),v._v(" "),e("li",[v._v("SPA路由原理")]),v._v(" "),e("li",[v._v("本地存储localStorage、sessionStorage与cookie之间的区别")])]),v._v(" "),e("h2",{attrs:{id:"vue"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#vue","aria-hidden":"true"}},[v._v("#")]),v._v(" Vue")]),v._v(" "),e("ul",[e("li",[v._v("深入Vue的响应原理?")]),v._v(" "),e("li",[v._v("Vue多版本之间的区别(运行时依赖,运行时编译)?")]),v._v(" "),e("li",[v._v("Vue中computed、watch与methods的区别")]),v._v(" "),e("li",[v._v("多种指令与自定义指令")]),v._v(" "),e("li",[v._v("路由传参与导航守卫")]),v._v(" "),e("li",[v._v("Element UI && so on")])]),v._v(" "),e("h2",{attrs:{id:"react"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#react","aria-hidden":"true"}},[v._v("#")]),v._v(" React")]),v._v(" "),e("ul",[e("li",[v._v("什么是MVVM?React与Vue的区别与联系?")]),v._v(" "),e("li",[v._v("JSX语法、Virtual DOM与DOM Diff算法?")]),v._v(" "),e("li",[v._v("详细介绍生命周期(三个阶段,生命周期的触发顺序)?")]),v._v(" "),e("li",[v._v("合成事件与改变this指向的三种方式及之间的区别?")]),v._v(" "),e("li",[v._v("样式绑定与CSS Modules")]),v._v(" "),e("li",[v._v("多种组件创建方式及其区别?什么是受控组件?")]),v._v(" "),e("li",[v._v("高阶组件与装饰器")]),v._v(" "),e("li",[v._v("组件通信的多种方式及其之间的区别")]),v._v(" "),e("li",[v._v("React Router及其简单实现")]),v._v(" "),e("li",[v._v("Redux数据流向及三个中间件(redux-logger、redux-thunk、redux-saga)")]),v._v(" "),e("li",[v._v("Ant Design && so on")])])])}],!1,null,null,null);_.default=i.exports}}]); -------------------------------------------------------------------------------- /lib/app/clientEntry.js: -------------------------------------------------------------------------------- 1 | /* global BASE_URL, GA_ID, ga, SW_ENABLED, VUEPRESS_VERSION, LAST_COMMIT_HASH*/ 2 | 3 | import { createApp } from './app' 4 | import SWUpdateEvent from './SWUpdateEvent' 5 | import { register } from 'register-service-worker' 6 | 7 | const { app, router } = createApp() 8 | 9 | window.__VUEPRESS_VERSION__ = { 10 | version: VUEPRESS_VERSION, 11 | hash: LAST_COMMIT_HASH 12 | } 13 | 14 | // Google analytics integration 15 | if (process.env.NODE_ENV === 'production' && GA_ID) { 16 | (function (i, s, o, g, r, a, m) { 17 | i['GoogleAnalyticsObject'] = r 18 | i[r] = i[r] || function () { 19 | (i[r].q = i[r].q || []).push(arguments) 20 | } 21 | i[r].l = 1 * new Date() 22 | a = s.createElement(o) 23 | m = s.getElementsByTagName(o)[0] 24 | a.async = 1 25 | a.src = g 26 | m.parentNode.insertBefore(a, m) 27 | })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga') 28 | 29 | ga('create', GA_ID, 'auto') 30 | ga('send', 'pageview') 31 | 32 | router.afterEach(function (to) { 33 | ga('set', 'page', to.fullPath) 34 | ga('send', 'pageview') 35 | }) 36 | } 37 | 38 | router.onReady(() => { 39 | app.$mount('#app') 40 | 41 | // Register service worker 42 | if (process.env.NODE_ENV === 'production' && 43 | SW_ENABLED && 44 | window.location.protocol === 'https:') { 45 | register(`${BASE_URL}service-worker.js`, { 46 | ready () { 47 | console.log('[vuepress:sw] Service worker is active.') 48 | app.$refs.layout.$emit('sw-ready') 49 | }, 50 | cached (registration) { 51 | console.log('[vuepress:sw] Content has been cached for offline use.') 52 | app.$refs.layout.$emit('sw-cached', new SWUpdateEvent(registration)) 53 | }, 54 | updated (registration) { 55 | console.log('[vuepress:sw] Content updated.') 56 | app.$refs.layout.$emit('sw-updated', new SWUpdateEvent(registration)) 57 | }, 58 | offline () { 59 | console.log('[vuepress:sw] No internet connection found. App is running in offline mode.') 60 | app.$refs.layout.$emit('sw-offline') 61 | }, 62 | error (err) { 63 | console.error('[vuepress:sw] Error during service worker registration:', err) 64 | app.$refs.layout.$emit('sw-error', err) 65 | if (GA_ID) { 66 | ga('send', 'exception', { 67 | exDescription: err.message, 68 | exFatal: false 69 | }) 70 | } 71 | } 72 | }) 73 | } 74 | }) 75 | -------------------------------------------------------------------------------- /lib/prepare/util.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | const spawn = require('cross-spawn') 3 | const fs = require('fs-extra') 4 | const globby = require('globby') 5 | 6 | const tempPath = path.resolve(__dirname, '../app/.temp') 7 | fs.ensureDirSync(tempPath) 8 | 9 | const tempCache = new Map() 10 | exports.writeTemp = async function (file, content) { 11 | // cache write to avoid hitting the dist if it didn't change 12 | const cached = tempCache.get(file) 13 | if (cached !== content) { 14 | await fs.writeFile(path.join(tempPath, file), content) 15 | tempCache.set(file, content) 16 | } 17 | } 18 | 19 | exports.writeEnhanceTemp = async function (destName, srcPath) { 20 | await exports.writeTemp( 21 | destName, 22 | fs.existsSync(srcPath) 23 | ? `export { default } from ${JSON.stringify(srcPath)}` 24 | : `export default function () {}` 25 | ) 26 | } 27 | 28 | const indexRE = /(^|.*\/)(index|readme)\.md$/i 29 | const extRE = /\.(vue|md)$/ 30 | 31 | exports.fileToPath = function (file) { 32 | if (exports.isIndexFile(file)) { 33 | // README.md -> / 34 | // foo/README.md -> /foo/ 35 | return file.replace(indexRE, '/$1') 36 | } else { 37 | // foo.md -> /foo.html 38 | // foo/bar.md -> /foo/bar.html 39 | return `/${file.replace(extRE, '').replace(/\\/g, '/')}.html` 40 | } 41 | } 42 | 43 | exports.fileToComponentName = function (file) { 44 | let normalizedName = file 45 | .replace(/\/|\\/g, '-') 46 | .replace(extRE, '') 47 | if (exports.isIndexFile(file)) { 48 | normalizedName = normalizedName.replace(/readme$/i, 'index') 49 | } 50 | const pagePrefix = /\.md$/.test(file) ? `page-` : `` 51 | return `${pagePrefix}${normalizedName}` 52 | } 53 | 54 | exports.isIndexFile = function (file) { 55 | return indexRE.test(file) 56 | } 57 | 58 | exports.resolveComponents = async function (sourceDir) { 59 | const componentDir = path.resolve(sourceDir, '.vuepress/components') 60 | if (!fs.existsSync(componentDir)) { 61 | return 62 | } 63 | return exports.sort(await globby(['**/*.vue'], { cwd: componentDir })) 64 | } 65 | 66 | exports.sort = function (arr) { 67 | return arr.sort((a, b) => { 68 | if (a < b) return -1 69 | if (a > b) return 1 70 | return 0 71 | }) 72 | } 73 | 74 | exports.encodePath = function (userpath) { 75 | return userpath.split('/').map(item => encodeURIComponent(item)).join('/') 76 | } 77 | 78 | exports.getGitLastUpdatedTimeStamp = function (filepath) { 79 | return parseInt(spawn.sync('git', ['log', '-1', '--format=%ct', filepath]).stdout.toString('utf-8')) * 1000 80 | } 81 | -------------------------------------------------------------------------------- /docs/assets/js/56.627b1a35.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[56],{158:function(e,t,a){"use strict";a.r(t);var r=a(0),s=Object(r.a)({},function(){this.$createElement;this._self._c;return this._m(0)},[function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("div",{staticClass:"content"},[a("h1",{attrs:{id:"redux中间件"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#redux中间件","aria-hidden":"true"}},[e._v("#")]),e._v(" Redux中间件")]),e._v(" "),a("h5",{attrs:{id:"_1、applymiddleware"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#_1、applymiddleware","aria-hidden":"true"}},[e._v("#")]),e._v(" 1、applyMiddleware")]),e._v(" "),a("ul",[a("li",[e._v("方便调试,实时触发,线下使用")])]),e._v(" "),a("div",{staticClass:"language- extra-class"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v("import {createStore,applyMiddleware} from 'redux';\nimport reducers from './reducers';\nimport Logger from 'redux-logger';\n\nexport default createStore(reducers, applyMiddleware(Logger))\n")])])]),a("h5",{attrs:{id:"_2、redux-thunk"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#_2、redux-thunk","aria-hidden":"true"}},[e._v("#")]),e._v(" 2、redux-thunk")]),e._v(" "),a("ul",[a("li",[e._v("目的:异步解决方案")]),e._v(" "),a("li",[e._v("支持action的写法有对象变为函数")]),e._v(" "),a("li",[e._v("可以发送多个dispatch")]),e._v(" "),a("li",[e._v("改变action")]),e._v(" "),a("li",[e._v("同时会帮我们注入两个参数dispatch和getState")]),e._v(" "),a("li",[e._v("在异步操作完成之后再触发dispatch操作")])]),e._v(" "),a("div",{staticClass:"language- extra-class"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[e._v('dispatch((dispatch, getState)=>{\n // getState可以获取全局的state\n dispatch({\n type:"START"\n })\n fetch(\'/data.json\')\n .then(res=>res.json())\n .then(success=>{\n if(success){\n dispatch({\n type:"FETCH_LIST",\n payLoad:success.arr\n })\n }else{\n dispatch({\n type:"FETCH_TAIL"\n })\n }\n })\n})\n')])])]),a("h5",{attrs:{id:"_3、redux-saga"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#_3、redux-saga","aria-hidden":"true"}},[e._v("#")]),e._v(" 3、redux-saga")]),e._v(" "),a("ul",[a("li",[e._v("拦截请求")]),e._v(" "),a("li",[e._v("解决异步")]),e._v(" "),a("li",[e._v("不会改变action")]),e._v(" "),a("li",[e._v("take 拦截")]),e._v(" "),a("li",[e._v("takeEvery 每次都拦截")])]),e._v(" "),a("h5",{attrs:{id:"_4、redux-thunk"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#_4、redux-thunk","aria-hidden":"true"}},[e._v("#")]),e._v(" 4、redux-thunk")]),e._v(" "),a("ul",[a("li",[e._v("改写action")])])])}],!1,null,null,null);t.default=s.exports}}]); -------------------------------------------------------------------------------- /docs/assets/js/36.529eaf6d.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[36],{178:function(t,a,e){"use strict";e.r(a);var r=e(0),s=Object(r.a)({},function(){this.$createElement;this._self._c;return this._m(0)},[function(){var t=this,a=t.$createElement,e=t._self._c||a;return e("div",{staticClass:"content"},[e("h1",{attrs:{id:"今日头条小程序的接口"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#今日头条小程序的接口","aria-hidden":"true"}},[t._v("#")]),t._v(" 今日头条小程序的接口")]),t._v(" "),e("h2",{attrs:{id:"首页"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#首页","aria-hidden":"true"}},[t._v("#")]),t._v(" 首页")]),t._v(" "),e("h3",{attrs:{id:"获取顶部tab"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#获取顶部tab","aria-hidden":"true"}},[t._v("#")]),t._v(" 获取顶部tab")]),t._v(" "),e("ul",[e("li",[t._v("url: get https://m.toutiao.com/pwa/api/wxapp/settings")])]),t._v(" "),e("h3",{attrs:{id:"分类tab切换"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#分类tab切换","aria-hidden":"true"}},[t._v("#")]),t._v(" 分类tab切换")]),t._v(" "),e("ul",[e("li",[t._v("url: get https://lf.snssdk.com/api/news/feed/v66/?language=zh-Hans-CN&count=20&category=[tab分类]&aid=1162&min_behot_time=[分页behot_time]&device_id=6650307045722932750")])]),t._v(" "),e("h3",{attrs:{id:"获取资讯详情"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#获取资讯详情","aria-hidden":"true"}},[t._v("#")]),t._v(" 获取资讯详情")]),t._v(" "),e("ul",[e("li",[t._v("url: get https://m.toutiao.com/pwa/api/wxapp/info/[资讯的id]/")])]),t._v(" "),e("h3",{attrs:{id:"获取资讯评论"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#获取资讯评论","aria-hidden":"true"}},[t._v("#")]),t._v(" 获取资讯评论")]),t._v(" "),e("ul",[e("li",[t._v("url: get https://ib.snssdk.com/article/v1/tab_comments/?group_id=[资讯的id]&&tab_index=0&count=[分页数量]&offset=[分页偏移]")])]),t._v(" "),e("h3",{attrs:{id:"生成小程序码"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#生成小程序码","aria-hidden":"true"}},[t._v("#")]),t._v(" 生成小程序码")]),t._v(" "),e("ul",[e("li",[t._v("url: get https://m.toutiao.com/pwa/api/wxapp/wxacode/?id=[资讯的id]&group_id=[资讯的id]&channel=0&page=pages/detail/detail")])]),t._v(" "),e("h3",{attrs:{id:"搜索提示接口"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#搜索提示接口","aria-hidden":"true"}},[t._v("#")]),t._v(" 搜索提示接口")]),t._v(" "),e("ul",[e("li",[t._v("url: get https://lf.snssdk.com/2/article/search_sug/?keyword=[搜索关键字]&device_id=6650307045722932750")])]),t._v(" "),e("h3",{attrs:{id:"搜索结果接口"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#搜索结果接口","aria-hidden":"true"}},[t._v("#")]),t._v(" 搜索结果接口")]),t._v(" "),e("ul",[e("li",[t._v("url: get https://lf.snssdk.com/api/2/wap/search_content/?keyword=[搜索关键字]&count=10&format=json&offset=[分页偏移]&search_text=[搜索提示结果]&device_id=6650307045722932750")])])])}],!1,null,null,null);a.default=s.exports}}]); -------------------------------------------------------------------------------- /docs/assets/js/42.219bb0ac.js: -------------------------------------------------------------------------------- 1 | (window.webpackJsonp=window.webpackJsonp||[]).push([[42],{172:function(a,e,t){"use strict";t.r(e);var s=t(0),r=Object(s.a)({},function(){this.$createElement;this._self._c;return this._m(0)},[function(){var a=this,e=a.$createElement,t=a._self._c||e;return t("div",{staticClass:"content"},[t("h1",{attrs:{id:"wxs"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#wxs","aria-hidden":"true"}},[a._v("#")]),a._v(" WXS")]),a._v(" "),t("h5",{attrs:{id:"wxs是什么?"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#wxs是什么?","aria-hidden":"true"}},[a._v("#")]),a._v(" wxs是什么?")]),a._v(" "),t("blockquote",[t("p",[a._v("WXS(WeiXin Script)是小程序的一套脚本语言,结合 WXML,可以构建出页面的结构。")])]),a._v(" "),t("h5",{attrs:{id:"注意"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#注意","aria-hidden":"true"}},[a._v("#")]),a._v(" 注意")]),a._v(" "),t("ol",[t("li",[a._v("wxs 不依赖于运行时的基础库版本,可以在所有版本的小程序中运行。")]),a._v(" "),t("li",[a._v("wxs 与 javascript 是不同的语言,有自己的语法,并不和 javascript 一致。")]),a._v(" "),t("li",[a._v("wxs 的运行环境和其他 javascript 代码是隔离的,wxs 中不能调用其他 javascript文件中定义的函数,也不能调用小程序提供的API。")]),a._v(" "),t("li",[a._v("wxs 函数不能作为组件的事件回调。")]),a._v(" "),t("li",[a._v("由于运行环境的差异,在 iOS 设备上小程序内的 wxs 会比 javascript 代码快 2 ~ 20 倍。在 android 设备上二者运行效率无差异。")])]),a._v(" "),t("h5",{attrs:{id:"页面渲染"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#页面渲染","aria-hidden":"true"}},[a._v("#")]),a._v(" 页面渲染")]),a._v(" "),t("div",{staticClass:"language- extra-class"},[t("pre",{pre:!0,attrs:{class:"language-text"}},[t("code",[a._v('\x3c!--wxml--\x3e\n\n var msg = "hello world";\n\n module.exports.message = msg;\n\n\n {{m1.message}} \n\n\n页面输出\nhello world\n')])])]),t("h5",{attrs:{id:"数据处理"}},[t("a",{staticClass:"header-anchor",attrs:{href:"#数据处理","aria-hidden":"true"}},[a._v("#")]),a._v(" 数据处理")]),a._v(" "),t("div",{staticClass:"language- extra-class"},[t("pre",{pre:!0,attrs:{class:"language-text"}},[t("code",[a._v("// page.js\nPage({\n data: {\n array: [1, 2, 3, 4, 5, 1, 2, 3, 4]\n }\n})\n")])])]),t("div",{staticClass:"language- extra-class"},[t("pre",{pre:!0,attrs:{class:"language-text"}},[t("code",[a._v('\x3c!--wxml--\x3e\n\x3c!-- 下面的 getMax 函数,接受一个数组,且返回数组中最大的元素的值 --\x3e\n\nvar getMax = function(array) {\n var max = undefined;\n for (var i = 0; i < array.length; ++i) {\n max = max === undefined ? \n array[i] : \n (max >= array[i] ? max : array[i]);\n }\n return max;\n}\n\nmodule.exports.getMax = getMax;\n\n\n\x3c!-- 调用 wxs 里面的 getMax 函数,参数为 page.js 里面的 array --\x3e\n {{m1.getMax(array)}} \n')])])]),t("p",[a._v("页面输出")]),a._v(" "),t("div",{staticClass:"language- extra-class"},[t("pre",{pre:!0,attrs:{class:"language-text"}},[t("code",[a._v("5\n")])])])])}],!1,null,null,null);e.default=r.exports}}]); --------------------------------------------------------------------------------