hinesboy / mavonEditor

mavonEditor - A markdown editor based on Vue that supports a variety of personalized features
http://www.mavoneditor.com/
MIT License
6.45k stars 918 forks source link

Property '$img2Url' does not exist on type 'Vue' #541

Open HammerChen opened 4 years ago

HammerChen commented 4 years ago

mavon-editor 版本:^2.7.7

main.ts 全局引用

前端代码:

<el-form-item>
    <div class="editor">
        <mavon-editor ref="md" @imgAdd="$imgAdd" v-model="data.content" style="height: 100%"></mavon-editor>
    </div>
</el-form-item>
<script lang="ts">
async $imgAdd(pos, $file) {
    const formdata = new FormData()
    formdata.append('file', $file)
    const res = await this.$http.post('upload', formdata)
    this.$refs.md.$img2Url(pos, res.data.url)
  }
</script>

功能正常,但是终端报错:

Property '$img2Url' does not exist on type 'Vue | Element | Vue[] | Element[]'.
Property '$img2Url' does not exist on type 'Vue'.

搜了网上类似的报错,基本上是说要声明 any ,试过了,还是报一样的错,有没有遇到一样问题的?是怎么解决的呢?😂😂😂

HammerChen commented 4 years ago

已解决,这样写就不报错了,但应该也只是暂时的过渡方案 image