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

Problem with $img2Url #458

Open ghost opened 5 years ago

ghost commented 5 years ago

Hi, I read many of issues and translate them. but i can't figure out what is problem of $img2Url function! Here is my code:

async $imgAdd(pos, $file) {
      const fd = new FormData()
      fd.append('photo', $file)
      fd.append('title', this.title)
      fd.append('categoryId', JSON.stringify(this.category))
      await this.$axios.post('post/photo', fd).then(response => {
        this.$refs.md.$img2Url(pos, response.data.photoInfo.url)
      })
    },

But i got this error:

vendors.app.js:2651 error TypeError: Cannot set property '0' of undefined
    at VueComponent.$changeUrl (vendors.app.js:23040)
    at VueComponent.$img2Url (vendors.app.js:23040)
    at index.1d58fe64d01b0adb4e15.hot-update.js:350
ghost commented 4 years ago

pos begin with 1, so you can try this.$refs.md.$img2Url(pos + 1, response.data.photoInfo.url)

pdt590 commented 4 years ago

I got same issue

monicaHsiao commented 2 years ago

I got same issue