index.html 975 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. <!-- Delete ".min" for console warnings in development -->
  10. <script src="../../dist/vue.min.js"></script>
  11. </head>
  12. <body>
  13. <div id="editor">
  14. <textarea :value="input" @input="update"></textarea>
  15. <div v-html="compiledMarkdown"></div>
  16. </div>
  17. <script>
  18. new Vue({
  19. el: '#editor',
  20. data: {
  21. input: '# hello'
  22. },
  23. computed: {
  24. compiledMarkdown: function () {
  25. return marked(this.input, { sanitize: true })
  26. }
  27. },
  28. methods: {
  29. update: _.debounce(function (e) {
  30. this.input = e.target.value
  31. }, 300)
  32. }
  33. })
  34. </script>
  35. </body>
  36. </html>