miaolz123 / vue-markdown

A Powerful and Highspeed Markdown Parser for Vue
https://miaolz123.github.io/vue-markdown/
MIT License
1.92k stars 258 forks source link

vue2 node 模式下 :source 无法使用 #9

Closed pjialin closed 7 years ago

pjialin commented 7 years ago

使用:source没有效果

检查下了源码,发现 mounted 中 没有处理 :source 这样的方式,简单修改了下,希望作者修复下

修改前:

153   mounted() {
154     if (this.$el.childNodes.length > 0) {
155       this.source = ''
156       for (let el of this.$el.childNodes) {
157         const ext = el.outerHTML ? el.outerHTML : el.textContent
158         this.sourceOut += ext
159       }
160     }
161     rende(this)
162     this.$watch('source', () => { rende(this) })
163     this.watches.forEach((v) => {
164       this.$watch(v, () => { rende(this) })
165     })
166   },

修改后:

153   mounted() {
154     if (this.$el.childNodes.length > 0) {
155       this.source = ''
156       for (let el of this.$el.childNodes) {
157         const ext = el.outerHTML ? el.outerHTML : el.textContent
158         this.sourceOut += ext
159       }
160     }else{
161         this.sourceOut = this.source
162     }
163     rende(this)
164     this.$watch('source', () => { this.sourceOut = this.source; rende(this) })
165     this.watches.forEach((v) => {
166       this.$watch(v, () => { rende(this) })
167     })
168   },
pjialin commented 7 years ago

还是不行

TypeError: _this2.rende is not a function
miaolz123 commented 7 years ago

现在应该可以了吧?

pjialin commented 7 years ago

ok 了 thanks

miaolz123 commented 7 years ago

@pjialin 这个确实是我的失误,应该我说谢谢的,欢迎继续提issue哈