-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Fix Vue Reactivity #1271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Fix Vue Reactivity #1271
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f385e21
Fix Vue compatibility (fix #790)
jhildenbiddle aa1d1e6
Merge branch 'develop' into fix-790
jhildenbiddle dd88248
Fix tests
jhildenbiddle 105fbbf
Updates per request
jhildenbiddle 78c2a9d
Merge remote-tracking branch 'origin/develop' into fix-790
jhildenbiddle cea9129
Add NODE_MODULES_URL global
jhildenbiddle 9b794f5
Show dir listing & help msg for manual instance
jhildenbiddle b135f84
Add Vue 3 compatibility
jhildenbiddle 3a4da88
Fix friendly message display
jhildenbiddle 094a503
Remove Cypress screenshots
jhildenbiddle 4f6148d
Merge branch 'develop' into fix-790
sy-records File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +1,145 @@ | ||
# Compatible with Vue | ||
# Vue compatibility | ||
|
||
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. | ||
Docsify allows [Vue.js](https://vuejs.org) components to be added directly to you Markdown files. These components can greatly simplify working with data and adding reactivity to your content. | ||
|
||
## Basic usage | ||
|
||
Load the Vue in `./index.html`. | ||
To get started, load either the production (minified) or development (unminified) version of Vue in your `index.html`: | ||
|
||
```html | ||
<script src="//cdn.jsdelivr.net/npm/vue"></script> | ||
<script src="//cdn.jsdelivr.net/npm/docsify"></script> | ||
<!-- Production (minified) --> | ||
<script src="//cdn.jsdelivr.net/npm/vue@2/dist/vue.min.js"></script> | ||
|
||
<!-- 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> | ||
<!-- Development (unminified, with debugging info via console) --> | ||
<script src="//cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script> | ||
``` | ||
|
||
Then you can immediately write Vue code at Markdown file. `new Vue({ el: '#main' })` script is executed by default to create instance. | ||
|
||
*README.md* | ||
## Basic rendering | ||
|
||
````markdown | ||
# Vue guide | ||
Docsify will automatically render basic Vue content that does not require `data`, `methods`, or other instance features. | ||
|
||
`v-for` usage. | ||
```markdown | ||
<button v-on:click.native="this.alert('Hello, World!')">Say Hello</button> | ||
|
||
```html | ||
<ul> | ||
<li v-for="i in 10">{{ i }}</li> | ||
<li v-for="i in 3">{{ i }}</li> | ||
</ul> | ||
``` | ||
|
||
The HTML above will render the following: | ||
|
||
<button v-on:click="this.alert('Hello, World!')">Say Hello</button> | ||
|
||
<ul> | ||
<li v-for="i in 10">{{ i }}</li> | ||
<li v-for="i in 3">{{ i }}</li> | ||
</ul> | ||
```` | ||
|
||
You can manually initialize a Vue instance. | ||
## Advanced usage | ||
|
||
*README.md* | ||
Vue components and templates that require `data`, `methods`, computed properties, lifecycle hooks, etc. require manually creating a new `Vue()` instance within a `<script>` tag in your markdown. | ||
|
||
```markdown | ||
# Vue demo | ||
<div id="example-1"> | ||
<p>{{ message }}</p> | ||
|
||
<button v-on:click="hello">Say Hello</button> | ||
|
||
<div id="main">hello {{ msg }}</div> | ||
<button v-on:click="counter -= 1">-</button> | ||
{{ counter }} | ||
<button v-on:click="counter += 1">+</button> | ||
</div> | ||
``` | ||
|
||
```markdown | ||
<script> | ||
new Vue({ | ||
el: '#main', | ||
data: { msg: 'Vue' } | ||
}) | ||
el: "#example-1", | ||
data: function() { | ||
counter: 0, | ||
message: "Hello, World!" | ||
}, | ||
methods: { | ||
hello: function() { | ||
alert(this.message); | ||
} | ||
} | ||
}); | ||
</script> | ||
``` | ||
|
||
!> In a Markdown file, only the script within the first script tag is executed. | ||
The HTML & JavaScript above will render the following: | ||
|
||
<div id="example-1"> | ||
<p>{{ message }}</p> | ||
|
||
<button v-on:click="hello">Say Hello</button> | ||
|
||
<button v-on:click="counter -= 1">-</button> | ||
{{ counter }} | ||
<button v-on:click="counter += 1">+</button> | ||
</div> | ||
|
||
## Combine Vuep to write playground | ||
!> Only the first `<script>` tag in a markdown file is executed. If you are working with multiple Vue components, all `Vue` instances must be created within this tag. | ||
|
||
[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. | ||
## Vuep playgrounds | ||
|
||
*index.html* | ||
[Vuep](https://github.com/QingWei-Li/vuep) is a Vue component that provides a live editor and preview for Vue content. See the [vuep documentation](https://qingwei-li.github.io/vuep/) for details. | ||
|
||
Add Vuep CSS and JavaScript to your `index.html`: | ||
|
||
```html | ||
<!-- Inject CSS file --> | ||
<!-- Vuep CSS --> | ||
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/vuep/dist/vuep.css"> | ||
|
||
<!-- 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> | ||
|
||
<!-- or use the compressed files --> | ||
<script src="//cdn.jsdelivr.net/npm/vue/dist/vue.min.js"></script> | ||
<!-- Vuep JavaScript --> | ||
<script src="//cdn.jsdelivr.net/npm/vuep/dist/vuep.min.js"></script> | ||
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script> | ||
``` | ||
|
||
*README.md* | ||
```markdown | ||
# Vuep | ||
Add vuep markup to a markdown file (e.g. `README.md`): | ||
|
||
<vuep template="#example"></vuep> | ||
```markdown | ||
<vuep template="#example-2"></vuep> | ||
|
||
<script v-pre type="text/x-template" id="example"> | ||
<script v-pre type="text/x-template" id="example-2"> | ||
<template> | ||
<div>Hello, {{ name }}!</div> | ||
</template> | ||
|
||
<script> | ||
module.exports = { | ||
data: function () { | ||
data: function() { | ||
return { name: 'Vue' } | ||
} | ||
} | ||
</script> | ||
</script> | ||
``` | ||
|
||
?> Example Refer to the [Vuep documentation](https://qingwei-li.github.io/vuep/). | ||
<vuep template="#example-2"></vuep> | ||
|
||
<script v-pre type="text/x-template" id="example-2"> | ||
<template> | ||
<div>Hello, {{ name }}!</div> | ||
</template> | ||
|
||
<script> | ||
module.exports = { | ||
data: function() { | ||
return { name: 'World' } | ||
} | ||
} | ||
</script> | ||
</script> | ||
|
||
<script> | ||
new Vue({ | ||
el: "#example-1", | ||
data: { | ||
counter: 0, | ||
message: "Hello, World!" | ||
}, | ||
methods: { | ||
hello: function() { | ||
alert(this.message); | ||
} | ||
} | ||
}); | ||
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.