index.html 908 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Vue.js markdown editor example</title>
  6. <link rel="stylesheet" href="style.css">
  7. <script src="https://unpkg.com/marked@0.3.6"></script>
  8. <script src="https://unpkg.com/lodash@4.16.0"></script>
  9. <script src="../../dist/vue.js"></script>
  10. </head>
  11. <body>
  12. <div id="editor">
  13. <textarea :value="input" @input="update"></textarea>
  14. <div v-html="compiledMarkdown"></div>
  15. </div>
  16. <script>
  17. new Vue({
  18. el: '#editor',
  19. data: {
  20. input: '# hello'
  21. },
  22. computed: {
  23. compiledMarkdown: function () {
  24. return marked(this.input, { sanitize: true })
  25. }
  26. },
  27. methods: {
  28. update: _.debounce(function (e) {
  29. this.input = e.target.value
  30. }, 300)
  31. }
  32. })
  33. </script>
  34. </body>
  35. </html>