vue2/examples/markdown/index.html

40 lines
975 B
HTML
Raw Normal View History

2016-04-16 04:20:35 +08:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Vue.js markdown editor example</title>
<link rel="stylesheet" href="style.css">
2016-09-19 23:35:42 +08:00
<script src="https://unpkg.com/marked@0.3.6"></script>
<script src="https://unpkg.com/lodash@4.16.0"></script>
<!-- Delete ".min" for console warnings in development -->
<script src="../../dist/vue.min.js"></script>
2016-04-16 04:20:35 +08:00
</head>
<body>
<div id="editor">
<textarea :value="input" @input="update"></textarea>
2016-09-19 23:35:42 +08:00
<div v-html="compiledMarkdown"></div>
2016-04-16 04:20:35 +08:00
</div>
<script>
new Vue({
el: '#editor',
data: {
input: '# hello'
},
2016-09-19 23:35:42 +08:00
computed: {
compiledMarkdown: function () {
return marked(this.input, { sanitize: true })
}
},
2016-04-16 04:20:35 +08:00
methods: {
2016-04-16 14:44:48 +08:00
update: _.debounce(function (e) {
2016-04-16 04:20:35 +08:00
this.input = e.target.value
2016-04-16 14:44:48 +08:00
}, 300)
2016-04-16 04:20:35 +08:00
}
})
</script>
</body>
</html>