2017-02-13 22:43:58 +08:00
# Configuration
2020-05-22 16:42:40 +08:00
You can configure Docsify by defining `window.$docsify` as an object:
2017-02-13 22:43:58 +08:00
```html
< script >
window.$docsify = {
2018-07-01 13:48:44 +08:00
repo: 'docsifyjs/docsify',
2017-02-13 22:43:58 +08:00
maxLevel: 3,
2020-02-21 00:49:31 +08:00
coverpage: true,
};
2017-02-13 22:43:58 +08:00
< / script >
```
2020-07-26 17:19:02 +08:00
The config can also be defined as a function, in which case the first argument is the Docsify `vm` instance. The function should return a config object. This can be useful for referencing `vm` in places like the markdown configuration:
2020-05-22 16:42:40 +08:00
```html
< script >
window.$docsify = function(vm) {
return {
markdown: {
renderer: {
code(code, lang) {
// ... use `vm` ...
},
},
},
};
};
< / script >
```
2017-02-13 22:43:58 +08:00
## el
2018-06-19 08:19:21 +08:00
- Type: `String`
- Default: `#app`
2017-02-13 22:43:58 +08:00
2020-07-26 17:19:02 +08:00
The DOM element to be mounted on initialization. It can be a CSS selector string or an actual [HTMLElement ](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement ).
2017-02-13 22:43:58 +08:00
```js
window.$docsify = {
2020-02-21 00:49:31 +08:00
el: '#app',
2018-02-11 19:49:50 +08:00
};
2017-02-13 22:43:58 +08:00
```
## repo
2018-06-19 08:19:21 +08:00
- Type: `String`
- Default: `null`
2017-02-13 22:43:58 +08:00
2020-07-26 17:19:02 +08:00
Configure the repository url, or a string of `username/repo` can add the [GitHub Corner ](http://tholman.com/github-corners/ ) widget in the top right corner of the site.
2017-02-13 22:43:58 +08:00
```js
window.$docsify = {
2018-07-01 13:48:44 +08:00
repo: 'docsifyjs/docsify',
2017-02-13 22:43:58 +08:00
// or
2020-02-21 00:49:31 +08:00
repo: 'https://github.com/docsifyjs/docsify/',
2018-02-11 19:49:50 +08:00
};
2017-02-13 22:43:58 +08:00
```
2018-02-11 19:49:50 +08:00
## maxLevel
2017-02-13 22:43:58 +08:00
2018-06-19 08:19:21 +08:00
- Type: `Number`
- Default: `6`
2017-02-13 22:43:58 +08:00
Maximum Table of content level.
```js
window.$docsify = {
2020-02-21 00:49:31 +08:00
maxLevel: 4,
2018-02-11 19:49:50 +08:00
};
2017-02-13 22:43:58 +08:00
```
2018-02-11 19:49:50 +08:00
## loadNavbar
2017-02-13 22:43:58 +08:00
2018-06-19 08:19:21 +08:00
- Type: `Boolean|String`
- Default: `false`
2017-02-13 22:43:58 +08:00
2020-07-26 17:19:02 +08:00
Loads navbar from the Markdown file `_navbar.md` if **true** , else loads it from the path specified.
2017-02-13 22:43:58 +08:00
```js
window.$docsify = {
// load from _navbar.md
loadNavbar: true,
// load from nav.md
2020-02-21 00:49:31 +08:00
loadNavbar: 'nav.md',
2018-02-11 19:49:50 +08:00
};
2017-02-13 22:43:58 +08:00
```
2018-02-11 19:49:50 +08:00
## loadSidebar
2017-02-13 22:43:58 +08:00
2018-06-19 08:19:21 +08:00
- Type: `Boolean|String`
- Default: `false`
2017-02-13 22:43:58 +08:00
2020-07-26 17:19:02 +08:00
Loads sidebar from the Markdown file `_sidebar.md` if **true** , else loads it from the path specified.
2017-02-13 22:43:58 +08:00
```js
window.$docsify = {
// load from _sidebar.md
loadSidebar: true,
// load from summary.md
2020-02-21 00:49:31 +08:00
loadSidebar: 'summary.md',
};
```
## hideSidebar
- Type : `Boolean`
- Default: `true`
2020-07-26 17:19:02 +08:00
This option will completely hide your sidebar and won't render any content on the side.
2020-02-21 00:49:31 +08:00
```js
window.$docsify = {
hideSidebar: true,
2018-02-11 19:49:50 +08:00
};
2017-02-13 22:43:58 +08:00
```
2018-02-11 19:49:50 +08:00
## subMaxLevel
2017-02-13 22:43:58 +08:00
2018-06-19 08:19:21 +08:00
- Type: `Number`
- Default: `0`
2017-02-13 22:43:58 +08:00
2017-03-10 05:19:07 +08:00
Add table of contents (TOC) in custom sidebar.
2017-02-13 22:43:58 +08:00
```js
window.$docsify = {
2020-02-21 00:49:31 +08:00
subMaxLevel: 2,
2018-02-11 19:49:50 +08:00
};
2017-02-13 22:43:58 +08:00
```
## auto2top
2018-06-19 08:19:21 +08:00
- Type: `Boolean`
- Default: `false`
2017-02-13 22:43:58 +08:00
Scrolls to the top of the screen when the route is changed.
```js
window.$docsify = {
2020-02-21 00:49:31 +08:00
auto2top: true,
2018-02-11 19:49:50 +08:00
};
2017-02-13 22:43:58 +08:00
```
## homepage
2018-06-19 08:19:21 +08:00
- Type: `String`
- Default: `README.md`
2017-02-13 22:43:58 +08:00
2020-07-26 17:19:02 +08:00
`README.md` in your docs folder will be treated as the homepage for your website, but sometimes you may need to serve another file as your homepage.
2017-02-13 22:43:58 +08:00
```js
window.$docsify = {
// Change to /home.md
homepage: 'home.md',
// Or use the readme in your repo
2018-02-11 19:49:50 +08:00
homepage:
2020-02-21 00:49:31 +08:00
'https://raw.githubusercontent.com/docsifyjs/docsify/master/README.md',
2018-02-11 19:49:50 +08:00
};
2017-02-13 22:43:58 +08:00
```
2020-05-12 16:46:06 +08:00
If you have a link to the homepage in the sidebar and want it to be shown as active when accessing the root url, make sure to update your sidebar accordingly:
```markdown
- Sidebar
- [Home ](/ )
- [Another page ](another.md )
```
For more details, see [#1131 ](https://github.com/docsifyjs/docsify/issues/1131 ).
2018-02-11 19:49:50 +08:00
## basePath
2017-02-13 22:43:58 +08:00
2018-06-19 08:19:21 +08:00
- Type: `String`
2017-02-13 22:43:58 +08:00
Base path of the website. You can set it to another directory or another domain name.
```js
window.$docsify = {
basePath: '/path/',
// Load the files from another site
basePath: 'https://docsify.js.org/',
// Even can load files from other repo
2018-02-11 19:49:50 +08:00
basePath:
2020-02-21 00:49:31 +08:00
'https://raw.githubusercontent.com/ryanmcdermott/clean-code-javascript/master/',
2018-02-11 19:49:50 +08:00
};
2017-02-13 22:43:58 +08:00
```
2018-12-06 22:30:58 +08:00
## relativePath
- Type: `Boolean`
- Default: `false`
2020-07-26 17:19:02 +08:00
If **true** , links are relative to the current context.
2018-12-06 22:30:58 +08:00
For example, the directory structure is as follows:
```text
.
└── docs
├── README.md
├── guide.md
└── zh-cn
├── README.md
├── guide.md
└── config
└── example.md
```
With relative path **enabled** and current URL `http://domain.com/zh-cn/README` , given links will resolve to:
```text
guide.md => http://domain.com/zh-cn/guide
config/example.md => http://domain.com/zh-cn/config/example
../README.md => http://domain.com/README
/README.md => http://domain.com/README
```
```js
window.$docsify = {
// Relative path enabled
relativePath: true,
// Relative path disabled (default value)
2020-02-21 00:49:31 +08:00
relativePath: false,
2018-12-06 22:30:58 +08:00
};
```
2017-02-13 22:43:58 +08:00
## coverpage
2018-06-19 08:19:21 +08:00
- Type: `Boolean|String|String[]|Object`
- Default: `false`
2017-02-13 22:43:58 +08:00
2017-03-25 15:52:21 +08:00
Activate the [cover feature ](cover.md ). If true, it will load from `_coverpage.md` .
2017-02-13 22:43:58 +08:00
```js
window.$docsify = {
coverpage: true,
// Custom file name
2018-02-11 20:12:07 +08:00
coverpage: 'cover.md',
// mutiple covers
coverpage: ['/', '/zh-cn/'],
// mutiple covers and custom file name
coverpage: {
'/': 'cover.md',
2020-02-21 00:49:31 +08:00
'/zh-cn/': 'cover.md',
},
2018-02-11 19:49:50 +08:00
};
2017-02-13 22:43:58 +08:00
```
2018-06-19 08:19:21 +08:00
## logo
- Type: `String`
2020-07-26 17:19:02 +08:00
Website logo as it appears in the sidebar. You can resize it by using CSS.
2018-06-19 08:19:21 +08:00
```js
window.$docsify = {
2020-02-21 00:49:31 +08:00
logo: '/_media/icon.svg',
2018-06-19 08:19:21 +08:00
};
```
2017-02-13 22:43:58 +08:00
## name
2018-06-19 08:19:21 +08:00
- Type: `String`
2017-02-13 22:43:58 +08:00
2017-03-10 05:19:07 +08:00
Website name as it appears in the sidebar.
2017-02-13 22:43:58 +08:00
```js
window.$docsify = {
2020-02-21 00:49:31 +08:00
name: 'docsify',
2018-02-11 19:49:50 +08:00
};
2017-02-13 22:43:58 +08:00
```
2019-12-30 04:28:26 +08:00
The name field can also contain custom HTML for easier customization:
```js
window.$docsify = {
2020-02-21 00:49:31 +08:00
name: '< span > docsify< / span > ',
2019-12-30 04:28:26 +08:00
};
```
2018-02-11 19:49:50 +08:00
## nameLink
2017-02-13 22:43:58 +08:00
2018-06-19 08:19:21 +08:00
- Type: `String`
- Default: `window.location.pathname`
2017-02-13 22:43:58 +08:00
2020-04-19 23:32:07 +08:00
The URL that the website `name` links to.
2017-02-13 22:43:58 +08:00
```js
window.$docsify = {
2017-02-28 20:57:32 +08:00
nameLink: '/',
// For each route
nameLink: {
'/zh-cn/': '/zh-cn/',
2020-02-21 00:49:31 +08:00
'/': '/',
},
2018-02-11 19:49:50 +08:00
};
2017-02-13 22:43:58 +08:00
```
## markdown
2018-06-19 08:19:21 +08:00
- Type: `Function`
2017-02-13 22:43:58 +08:00
2017-03-25 15:52:21 +08:00
See [Markdown configuration ](markdown.md ).
2017-02-13 22:43:58 +08:00
```js
window.$docsify = {
2017-02-19 00:11:16 +08:00
// object
markdown: {
smartypants: true,
renderer: {
link: function() {
// ...
2020-02-21 00:49:31 +08:00
},
},
2017-02-19 00:11:16 +08:00
},
// function
2018-02-11 19:49:50 +08:00
markdown: function(marked, renderer) {
2017-02-13 22:43:58 +08:00
// ...
2018-02-11 19:49:50 +08:00
return marked;
2020-02-21 00:49:31 +08:00
},
2018-02-11 19:49:50 +08:00
};
2017-02-13 22:43:58 +08:00
```
2018-02-11 19:49:50 +08:00
## themeColor
2017-02-13 22:43:58 +08:00
2018-06-19 08:19:21 +08:00
- Type: `String`
2017-02-13 22:43:58 +08:00
2017-03-10 05:19:07 +08:00
Customize the theme color. Use [CSS3 variables ](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables ) feature and polyfill in old browser.
2017-02-13 22:43:58 +08:00
```js
window.$docsify = {
2020-02-21 00:49:31 +08:00
themeColor: '#3F51B5',
2018-02-11 19:49:50 +08:00
};
2017-02-13 22:43:58 +08:00
```
## alias
2018-06-19 08:19:21 +08:00
- Type: `Object`
2017-02-13 22:43:58 +08:00
2017-07-10 22:23:09 +08:00
Set the route alias. You can freely manage routing rules. Supports RegExp.
2017-02-13 22:43:58 +08:00
```js
window.$docsify = {
alias: {
2017-07-10 22:23:09 +08:00
'/foo/(+*)': '/bar/$1', // supports regexp
2017-02-13 22:43:58 +08:00
'/zh-cn/changelog': '/changelog',
2018-02-11 19:49:50 +08:00
'/changelog':
2018-07-01 13:48:44 +08:00
'https://raw.githubusercontent.com/docsifyjs/docsify/master/CHANGELOG',
2020-02-21 00:49:31 +08:00
'/.*/_sidebar.md': '/_sidebar.md', // See #301
},
2018-02-11 19:49:50 +08:00
};
2017-02-13 22:43:58 +08:00
```
2017-02-18 22:12:17 +08:00
2018-02-11 19:49:50 +08:00
## autoHeader
2017-02-18 22:12:17 +08:00
2018-06-19 08:19:21 +08:00
- type: `Boolean`
2017-02-18 22:12:17 +08:00
2020-07-26 17:19:02 +08:00
If `loadSidebar` and `autoHeader` are both enabled, for each link in `_sidebar.md` , prepend a header to the page before converting it to HTML. Compare [#78 ](https://github.com/docsifyjs/docsify/issues/78 ).
2017-02-18 22:12:17 +08:00
```js
window.$docsify = {
loadSidebar: true,
2020-02-21 00:49:31 +08:00
autoHeader: true,
2018-02-11 19:49:50 +08:00
};
2017-02-18 22:12:17 +08:00
```
2017-02-18 23:04:52 +08:00
2018-02-11 19:49:50 +08:00
## executeScript
2017-02-18 23:04:52 +08:00
2018-06-19 08:19:21 +08:00
- type: `Boolean`
2017-02-18 23:04:52 +08:00
2018-02-11 19:49:50 +08:00
Execute the script on the page. Only parse the first script tag([demo](themes)). If Vue is present, it is turned on by default.
2017-02-18 23:04:52 +08:00
```js
window.$docsify = {
2020-02-21 00:49:31 +08:00
executeScript: true,
2018-02-11 19:49:50 +08:00
};
2017-02-18 23:04:52 +08:00
```
```markdown
## This is test
< script >
console.log(2333)
< / script >
```
2017-03-25 15:52:21 +08:00
Note that if you are running an external script, e.g. an embedded jsfiddle demo, make sure to include the [external-script ](plugins.md?id=external-script ) plugin.
2017-03-11 19:30:38 +08:00
2018-02-11 19:49:50 +08:00
## noEmoji
2017-03-11 19:30:38 +08:00
2018-06-19 08:19:21 +08:00
- type: `Boolean`
2017-07-10 22:23:09 +08:00
2017-03-11 19:30:38 +08:00
Disabled emoji parse.
```js
window.$docsify = {
2020-02-21 00:49:31 +08:00
noEmoji: true,
2018-02-11 19:49:50 +08:00
};
2017-03-11 19:30:38 +08:00
```
2017-04-09 12:10:37 +08:00
2020-02-14 23:11:53 +08:00
?> If this options is `false` but you dont want to emojify some specific colons , [Refer this ](https://github.com/docsifyjs/docsify/issues/742#issuecomment-586313143 )
2018-02-11 19:49:50 +08:00
## mergeNavbar
2017-04-09 12:10:37 +08:00
2018-06-19 08:19:21 +08:00
- type: `Boolean`
2017-07-10 22:23:09 +08:00
2017-04-09 12:10:37 +08:00
Navbar will be merged with the sidebar on smaller screens.
```js
window.$docsify = {
2020-02-21 00:49:31 +08:00
mergeNavbar: true,
2018-02-11 19:49:50 +08:00
};
2017-04-09 12:10:37 +08:00
```
2017-05-16 23:03:22 +08:00
2018-02-11 19:49:50 +08:00
## formatUpdated
2017-07-10 22:23:09 +08:00
2018-06-19 08:19:21 +08:00
- type: `String|Function`
2017-07-10 22:23:09 +08:00
2017-05-30 12:05:25 +08:00
We can display the file update date through ** {docsify-updated< span > }</ span > ** variable. And format it by `formatUpdated` .
2017-05-16 23:03:22 +08:00
See https://github.com/lukeed/tinydate#patterns
2018-02-11 19:49:50 +08:00
2017-05-16 23:03:22 +08:00
```js
window.$docsify = {
formatUpdated: '{MM}/{DD} {HH}:{mm}',
2018-02-11 19:49:50 +08:00
formatUpdated: function(time) {
2017-05-16 23:03:22 +08:00
// ...
2018-02-11 19:49:50 +08:00
return time;
2020-02-21 00:49:31 +08:00
},
2018-02-11 19:49:50 +08:00
};
2017-05-16 23:03:22 +08:00
```
2017-05-16 23:09:41 +08:00
2018-02-11 19:49:50 +08:00
## externalLinkTarget
2017-05-16 23:09:41 +08:00
2018-06-19 08:19:21 +08:00
- type: `String`
- default: `_blank`
2017-07-10 22:23:09 +08:00
2019-05-10 15:47:07 +08:00
Target to open external links inside the markdown. Default `'_blank'` (new window/tab)
2017-05-16 23:09:41 +08:00
```js
window.$docsify = {
2020-02-21 00:49:31 +08:00
externalLinkTarget: '_self', // default: '_blank'
2018-02-11 19:49:50 +08:00
};
2017-05-16 23:09:41 +08:00
```
2017-05-30 12:05:25 +08:00
2019-05-10 15:47:07 +08:00
## cornerExternalLinkTarget
- type:`String`
- default:`_blank`
Target to open external link at the top right corner. Default `'_blank'` (new window/tab)
```js
window.$docsify = {
2020-02-21 00:49:31 +08:00
cornerExternalLinkTarget: '_self', // default: '_blank'
2019-05-10 15:47:07 +08:00
};
```
2019-09-06 13:43:40 +08:00
## externalLinkRel
- type: `String`
- default: `noopener`
2020-07-26 17:19:02 +08:00
Default `'noopener'` (no opener) prevents the newly opened external page (when [externalLinkTarget ](#externallinktarget ) is `'_blank'` ) from having the ability to control our page. No `rel` is set when it's not `'_blank'` . See [this post ](https://mathiasbynens.github.io/rel-noopener/ ) for more information about why you may want to use this option.
2019-09-06 13:43:40 +08:00
```js
window.$docsify = {
2020-05-04 18:57:24 +08:00
externalLinkRel: '', // default: 'noopener'
2019-09-06 13:43:40 +08:00
};
```
2018-02-11 19:49:50 +08:00
## routerMode
2017-07-10 22:23:09 +08:00
2018-06-19 08:19:21 +08:00
- type: `String`
2018-06-25 21:17:02 +08:00
- default: `hash`
2017-07-10 22:23:09 +08:00
2017-05-30 12:05:25 +08:00
```js
window.$docsify = {
2020-02-21 00:49:31 +08:00
routerMode: 'history', // default: 'hash'
2018-02-11 19:49:50 +08:00
};
2017-05-30 12:05:25 +08:00
```
2017-07-10 22:38:26 +08:00
2020-10-08 07:00:08 +08:00
## crossOriginLinks
2020-10-21 06:45:34 +08:00
- type: `Array`
When `routerMode: 'history'` , you may face the cross-origin issues, See [#1379 ](https://github.com/docsifyjs/docsify/issues/1379 ).
In Markdown content, there is a simple way to solve it, see extends Markdown syntax `Cross-Origin link` in [helpers ](helpers.md ).
2020-10-08 07:00:08 +08:00
```js
window.$docsify = {
2020-10-21 06:45:34 +08:00
crossOriginLinks: ['https://example.com/cross-origin-link'],
2020-10-08 07:00:08 +08:00
};
```
2017-07-10 22:38:26 +08:00
## noCompileLinks
2018-06-19 08:19:21 +08:00
- type: `Array`
2017-07-10 22:38:26 +08:00
2018-07-01 13:48:44 +08:00
Sometimes we do not want docsify to handle our links. See [#203 ](https://github.com/docsifyjs/docsify/issues/203 )
2017-07-10 22:38:26 +08:00
```js
window.$docsify = {
2020-02-21 00:49:31 +08:00
noCompileLinks: ['/foo', '/bar/.*'],
2018-02-11 19:49:50 +08:00
};
2017-07-10 22:38:26 +08:00
```
2018-02-11 20:12:07 +08:00
## onlyCover
2018-06-19 08:19:21 +08:00
- type: `Boolean`
2018-02-11 20:12:07 +08:00
2018-02-15 08:57:17 +08:00
Only coverpage is loaded when visiting the home page.
2018-02-11 20:12:07 +08:00
```js
window.$docsify = {
2020-02-21 00:49:31 +08:00
onlyCover: false,
2018-02-11 20:12:07 +08:00
};
```
2018-02-11 20:15:04 +08:00
## requestHeaders
2018-06-19 08:19:21 +08:00
- type: `Object`
2018-02-11 20:15:04 +08:00
Set the request resource headers.
```js
window.$docsify = {
requestHeaders: {
2020-02-21 00:49:31 +08:00
'x-token': 'xxx',
},
2018-02-11 20:15:04 +08:00
};
```
2019-12-22 19:46:23 +08:00
Such as setting the cache
```js
window.$docsify = {
requestHeaders: {
2020-02-21 00:49:31 +08:00
'cache-control': 'max-age=600',
},
2019-12-22 19:46:23 +08:00
};
```
2018-02-11 20:15:04 +08:00
## ext
2018-06-19 08:19:21 +08:00
- type: `String`
2018-02-11 20:15:04 +08:00
Request file extension.
```js
window.$docsify = {
2020-02-21 00:49:31 +08:00
ext: '.md',
2018-02-11 20:15:04 +08:00
};
```
2018-03-01 22:37:30 +08:00
## fallbackLanguages
2018-06-19 08:19:21 +08:00
- type: `Array<string>`
2018-03-01 22:37:30 +08:00
2020-07-26 17:19:02 +08:00
List of languages that will fallback to the default language when a page is requested and it doesn't exist for the given local.
2018-03-01 22:37:30 +08:00
2018-03-03 22:51:27 +08:00
Example:
2020-07-26 17:19:02 +08:00
- try to fetch the page of `/de/overview` . If this page exists, it'll be displayed.
- then try to fetch the default page `/overview` (depending on the default language). If this page exists, it'll be displayed.
- then display the 404 page.
2018-03-01 22:37:30 +08:00
```js
window.$docsify = {
2020-02-21 00:49:31 +08:00
fallbackLanguages: ['fr', 'de'],
2018-03-01 22:37:30 +08:00
};
```
2018-03-03 22:09:01 +08:00
## notFoundPage
2018-06-19 08:19:21 +08:00
- type: `Boolean` | `String` | `Object`
2018-03-03 22:09:01 +08:00
Load the `_404.md` file:
2018-06-19 08:19:21 +08:00
2018-03-03 22:09:01 +08:00
```js
window.$docsify = {
2020-02-21 00:49:31 +08:00
notFoundPage: true,
2018-03-03 22:09:01 +08:00
};
```
2020-07-26 17:19:02 +08:00
Load the customized path of the 404 page:
2018-06-19 08:19:21 +08:00
2018-03-03 22:09:01 +08:00
```js
window.$docsify = {
2020-02-21 00:49:31 +08:00
notFoundPage: 'my404.md',
2018-03-03 22:09:01 +08:00
};
```
Load the right 404 page according to the localisation:
2018-06-19 08:19:21 +08:00
2018-03-03 22:09:01 +08:00
```js
window.$docsify = {
notFoundPage: {
'/': '_404.md',
2020-02-21 00:49:31 +08:00
'/de': 'de/_404.md',
},
2018-03-03 22:09:01 +08:00
};
```
2018-06-19 08:19:21 +08:00
> Note: The options with fallbackLanguages didn't work with the `notFoundPage` options.
2020-03-09 16:49:31 +08:00
## topMargin
- type: `Number`
- default: `0`
Adds a space on top when scrolling content page to reach the selected section. This is useful in case you have a _sticky-header_ layout and you want to align anchors to the end of your header.
```js
window.$docsify = {
topMargin: 90, // default: 0
};
2020-04-19 23:32:07 +08:00
```
2020-10-21 06:45:34 +08:00
## vueComponents
- type: `Object`
2020-11-11 13:24:21 +08:00
Registers Vue components using the component name as the key with an object containing Vue options as the value. Component data is not shared and changes will not persist as users navigate the site.
2020-10-21 06:45:34 +08:00
```js
window.$docsify = {
vueComponents: {
'button-counter': {
template: `
< button @click =" count += 1 " >
You clicked me {{ count }} times
< / button >
`,
data() {
return {
count: 0,
};
},
},
},
};
```
```markdown
< button-counter > < / button-counter >
```
< output data-lang = "output" >
< button-counter > < / button-counter >
< / output >
## vueGlobalOptions
- type: `Object`
2020-10-22 02:14:07 +08:00
Specifies Vue options to be shared throughout your site. These options will be used when Docsify detects Vue content in the main content area that has not been previously mounted via [vueMountOptions ](#vuemountoptions ), [vueComponents ](#vuecomponents ), or a markdown `<script>` .
2020-10-21 06:45:34 +08:00
```js
window.$docsify = {
vueGlobalOptions: {
data() {
return {
count: 0,
};
},
},
};
```
```markdown
< p >
< button v-on:click = "count -= 1" > -< / button >
{{ count }}
< button v-on:click = "count += 1" > +< / button >
< / p >
```
< output data-lang = "output" >
< p >
< button v-on:click = "count -= 1" > -< / button >
{{ count }}
< button v-on:click = "count += 1" > +< / button >
< / p >
< / output >
2020-10-22 02:14:07 +08:00
## vueMountOptions
2020-10-21 06:45:34 +08:00
- type: `Object`
2020-11-11 13:24:21 +08:00
Specifies Vue mount elements and their associated options. Mount elements are specified using a [CSS selector ](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors ) as the key with an object containing Vue options as their value. Docsify will mount the first matching element in the main content area (`#main, .markdown-section`) each time a new page is loaded.
2020-10-21 06:45:34 +08:00
```js
window.$docsify = {
2020-10-22 02:14:07 +08:00
vueMountOptions: {
2020-10-21 06:45:34 +08:00
'#counter': {
data() {
return {
count: 0,
};
},
},
},
};
```
```markdown
< div id = "counter" >
< button v-on:click = "count -= 1" > -< / button >
{{ count }}
< button v-on:click = "count += 1" > +< / button >
< / div >
```
< output id = "counter" >
< button v-on:click = "count -= 1" > -< / button >
{{ count }}
< button v-on:click = "count += 1" > +< / button >
< / output >