https://cn.vuejs.org/v2/examples/

官网这个示例是用普通js方式的引入的vue,直接在html文件上写的,不够vue

安装几个包

npm i lodash -S
npm i marked -S

路由

export default new Router({routes: [{path: '/',name: 'HelloWorld',component: HelloWorld},{path: '/liveupdatemarkdown',name: 'LiveUpdateMarkdown',component: LiveUpdateMarkdown}]
})

完整组件

<template><div id="editor"><textarea :value="input" @input="update"></textarea><div v-html="compiledMarkdown"></div></div>
</template><script>import marked from 'marked'let _ = require('lodash')// Vue.prototype._ = _export default {name: "LiveUpdateMarkdown",data () {return {input: "# hello"};},computed: {compiledMarkdown: function() {return marked(this.input, { sanitize: true });}},methods: {update: _.debounce(function(e) {this.input = e.target.value;}, 300)}}
</script><style scoped>
html,
body,
#editor {margin: 0;height: 100%;font-family: "Helvetica Neue", Arial, sans-serif;color: #333;
}textarea,
#editor div {display: inline-block;width: 49%;height: 100%;vertical-align: top;box-sizing: border-box;padding: 0 20px;
}textarea {border: none;border-right: 1px solid #ccc;resize: none;outline: none;background-color: #f6f6f6;font-size: 14px;font-family: "Monaco", courier, monospace;padding: 20px;
}code {color: #f66;
}
</style>

【Vue.js】用vue组件完成官网实时markdown示例相关推荐

  1. vue手机端项目php,MintUI基于Vue.js移动端组件库详解

    Mint UI 包含丰富的 CSS 和 JS 组件,能够满足日常的移动端开发需要.接下来通过本文给大家分享Mint UI 基于 Vue.js 移动端组件库,需要的朋友参考下吧,希望能帮助到大家. 官网 ...

  2. vue使用html渲染组件,Vue.js在渲染组件之前填充数据

    我是Vue.js的新手,我试图创建一个没有成功的简单组件,它包含一个selectList,我试图填充它的选项数据来模拟Ajax请求,这是我的代码:Vue.js在渲染组件之前填充数据 HTML {{n. ...

  3. 动态添加组件_使用vue.js的动态组件模板

    最近刚做完建站工具,准备总结里面使用到的一些技巧,同时会做一版简化的放在 github上. 先来一篇翻译的文章,和我在项目中使用的动态组件思路一样,不过缺少了演化的过程,直接给出了最终的解决方案.这篇 ...

  4. vue图片裁剪组件_使用Vue-Rx的Vue.js图像裁剪组件

    vue图片裁剪组件 Vuejs夹 (vuejs-clipper) Vue.js image clipping components using Vue-Rx. 使用Vue-Rx的Vue.js图像裁剪组 ...

  5. Vue.js(一) Vue.js + element-ui 扫盲

    Vue.js(一) Vue.js + element-ui 扫盲 2018年12月09日 20:32:59 vbirdbest 阅读数 7043更多 分类专栏: Vue.js + ElementUI ...

  6. vue.js报错 vue.js:597 [Vue warn]: Cannot find element: #app

    刚开始使用vue的时候发现vue报vue.js:597 [Vue warn]: Cannot find element: #app的错误,初始以为是写的代码有错误导致,于是认真的对照了几遍发现代码和官 ...

  7. vue.js:597 [Vue warn]: Error in callback for watcher dat: TypeError: Cannot read property 'call'

    vue.js:597 [Vue warn]: Error in callback for watcher "dat": "TypeError: Cannot read p ...

  8. vue.js:590 [Vue tip]: Event “removeitem“ is emitted in component <TodoItems> but the handler is regi

    报错信息 vue.js:590 [Vue tip]: Event "removeitem" is emitted in component <TodoItems> bu ...

  9. Vue.js教程-Vue项目的目录结构和.vue文件的构成

    Vue.js教程-Vue项目的目录结构和.vue文件的构成 前言 Vue项目的目录结构(Vue-cli3/4版本) .vue文件的构成 Html区域(template) script区域 export ...

最新文章

  1. OpenGL从入门到精通--你好三角形
  2. Docker文件系统实战
  3. 非监督学习的单层网络分析
  4. 通过url来设置log4j的记录级别
  5. 走到尽头的技术-MVC
  6. ant更改主题色报错Inline JavaScript is not enabled. Is it set in your options? vue ant主题色更改 vue-cli3
  7. js 值太大自动转换bignumber
  8. 模板 - 多项式快速插值
  9. 佳能Canon imageCLASS MF236n 一体机驱动
  10. 安防大数据时代的IP摄像机发展
  11. Glide内存占用优化
  12. 【饭谈】谈谈所有人都曾经对测开技术的迷茫和恐惧
  13. c语言产生瑞利分布随机数,瑞利分布的随机数
  14. 使用Banner制作轮播图
  15. 从 WWDC17 看苹果图形技术的革新
  16. opengl简单模拟行星运转
  17. inspects a maven model for resolution problems
  18. web渗透--ftp暴力破解,明文、嗅探安全等
  19. 电销CRM客户关系管理系统开发12大核心功能
  20. 13位时间戳接口(淘宝、京东、苏宁、华为)

热门文章

  1. 发送邮件springboot-stater-mail
  2. 电话销售如何找对客户?
  3. python实现闭合导线平差与坐标计算(改进)
  4. 数据挖掘——SVM(乳腺癌检测)
  5. 成功促销:九大战术找准产品“卖点”
  6. 首届“千海金”杯信物文化珠宝设计赛在京启动
  7. java继承和多态的实验报告_Java继承与多态实验报告.doc
  8. 【jenkins打包maven项目报错记录】
  9. 词根词缀思维导图到底应该怎么画?
  10. java 安全登陆系统设计,基于JAVA的安全管理信息系统设计