You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
2.1 KiB

7 years ago
# Compatible with Vue
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.
7 years ago
## Basic usage
Load the Vue in `./index.html`.
7 years ago
```html
<script src="//unpkg.com/vue"></script>
<script src="//unpkg.com/docsify"></script>
<!-- Or use the compressed files -->
<script src="//unpkg.com/vue/dist/vue.min.js"></script>
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
7 years ago
```
Then you can immediately write Vue code at Markdown file. `new Vue({ el: '#main' })` script is executed by default to create instance.
7 years ago
*README.md*
````markdown
7 years ago
# Vue guide
`v-for` usage.
```html
<ul>
<li v-for="i in 10">{{ i }}</li>
</ul>
```
7 years ago
<ul>
<li v-for="i in 10">{{ i }}</li>
</ul>
````
7 years ago
You can manually initialize a Vue instance.
*README.md*
```markdown
# Vue demo
<div id="main">hello {{ msg }}</div>
7 years ago
<script>
new Vue({
7 years ago
el: '#main',
7 years ago
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
<!-- Inject CSS file -->
<link rel="stylesheet" href="//unpkg.com/vuep/dist/vuep.css">
<!-- Inject JavaScript file -->
7 years ago
<script src="//unpkg.com/vue"></script>
<script src="//unpkg.com/vuep"></script>
<script src="//unpkg.com/docsify"></script>
<!-- or use the compressed files -->
<script src="//unpkg.com/vue/dist/vue.min.js"></script>
<script src="//unpkg.com/vuep/dist/vuep.min.js"></script>
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
7 years ago
```
*README.md*
```markdown
# Vuep
<vuep template="#example"></vuep>
<script v-pre type="text/x-template" id="example">
7 years ago
<template>
<div>Hello, {{ name }}!</div>
</template>
<script>
7 years ago
module.exports = {
7 years ago
data: function () {
return { name: 'Vue' }
}
}
</script>
</script>
```
?> Example Refer to the [Vuep documentation](https://qingwei-li.github.io/vuep/).