docsify/docs/vue.md

100 lines
2.2 KiB
Markdown
Raw Normal View History

2017-02-13 22:43:58 +08:00
# Compatible with Vue
2017-03-10 05:19:07 +08:00
You can write Vue components directly in the Markdown file, and it will be parsed. You can use this feature to write vue demo and documentation together.
2017-02-13 22:43:58 +08:00
## Basic usage
2017-03-10 05:19:07 +08:00
Load the Vue in `./index.html`.
2017-02-13 22:43:58 +08:00
```html
<script src="//cdn.jsdelivr.net/npm/vue"></script>
<script src="//cdn.jsdelivr.net/npm/docsify"></script>
2017-03-10 05:19:07 +08:00
2018-07-11 07:24:47 +08:00
<!-- Or use the compressed files -->
<script src="//cdn.jsdelivr.net/npm/vue/dist/vue.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
2017-02-13 22:43:58 +08:00
```
2017-03-10 05:19:07 +08:00
Then you can immediately write Vue code at Markdown file. `new Vue({ el: '#main' })` script is executed by default to create instance.
2017-02-13 22:43:58 +08:00
*README.md*
2017-10-20 22:41:38 +08:00
````markdown
2017-02-13 22:43:58 +08:00
# Vue guide
`v-for` usage.
```html
<ul>
<li v-for="i in 10">{{ i }}</li>
</ul>
2017-09-13 16:38:09 +08:00
```
2017-02-13 22:43:58 +08:00
<ul>
<li v-for="i in 10">{{ i }}</li>
</ul>
2017-10-20 22:41:38 +08:00
````
2017-02-13 22:43:58 +08:00
You can manually initialize a Vue instance.
*README.md*
```markdown
# Vue demo
<div id="main">hello {{ msg }}</div>
2017-02-13 22:43:58 +08:00
<script>
new Vue({
2017-02-18 19:36:28 +08:00
el: '#main',
2017-02-13 22:43:58 +08:00
data: { msg: 'Vue' }
})
</script>
```
!> In a Markdown file, only the script within the first script tag is executed.
## Combine Vuep to write playground
[Vuep](https://github.com/QingWei-Li/vuep) is a component for rendering Vue components with live editor and preview. Supports Vue component spec and JSX.
*index.html*
```html
2018-07-11 07:24:47 +08:00
<!-- Inject CSS file -->
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/vuep/dist/vuep.css">
2017-03-11 18:27:43 +08:00
2018-07-11 07:24:47 +08:00
<!-- Inject JavaScript file -->
<script src="//cdn.jsdelivr.net/npm/vue"></script>
<script src="//cdn.jsdelivr.net/npm/vuep"></script>
<script src="//cdn.jsdelivr.net/npm/docsify"></script>
2017-03-10 05:19:07 +08:00
<!-- or use the compressed files -->
<script src="//cdn.jsdelivr.net/npm/vue/dist/vue.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/vuep/dist/vuep.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
2017-02-13 22:43:58 +08:00
```
*README.md*
```markdown
# Vuep
<vuep template="#example"></vuep>
2017-03-11 18:16:34 +08:00
<script v-pre type="text/x-template" id="example">
2017-02-13 22:43:58 +08:00
<template>
<div>Hello, {{ name }}!</div>
</template>
<script>
2017-02-21 14:05:58 +08:00
module.exports = {
2017-02-13 22:43:58 +08:00
data: function () {
return { name: 'Vue' }
}
}
</script>
</script>
```
2018-07-11 07:24:47 +08:00
?> Example Refer to the [Vuep documentation](https://qingwei-li.github.io/vuep/).