鍍金池/ 問答/網(wǎng)絡(luò)安全  HTML/ vue用marked、loads編譯markdown報(bào)錯(cuò)?

vue用marked、loads編譯markdown報(bào)錯(cuò)?

官網(wǎng)例子 markdown

請問以下報(bào)錯(cuò)可能是什么原因呢?

我的插件版本

{
    "marked": "^0.3.6",
    "lodash": "^4.16.0",
}

html

<div id="temp">
    <textarea :value="inpVal" @input="inpUpdate" class="input-box"></textarea>
    <div v-html="compiledMd" class="html-box"></div>
</div>

js

  import _ from 'lodash';
  import marked from 'marked';

  export default {
    name: 'temp',
    data() {
      return {
        inpVal: '# hello',
      }
    },
    computed: {
      compiledMd: function () {
        return marked(this.input, {sanitize: true})
      }
    },
    methods: {
      inpUpdate: _.debounce(function (e) {
        this.inpVal = e.target.value
      }, 300)
    }
  }

報(bào)錯(cuò)

clipboard.png

回答
編輯回答
柒槿年

注意下 this 指向問題, 沒有使用箭頭函數(shù)要注意 this

2018年5月27日 23:47
編輯回答
忘了我
\```
  code ...
 \```

遇到過這里不寫 language類型就報(bào)錯(cuò)的情況

2018年3月24日 12:14