miaolz123 / vue-markdown

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

Placing directive on anchor tag is not read by Vue Parser. #48

Open ghost opened 6 years ago

ghost commented 6 years ago

I am rendering an with a directive using vue-markdown.

When my App loads, it seems that my Vue instance is not parsing my rendered tag and thus not calling the appropriate directive.

I'm wondering if there is a prop i need to pass to the vue-markdown instance that will allow the Vue parser to pick up my 'nested' directive.

see example below.



const Foo = Vue.directive('foo', el => console.log('Element with directive', el));

new Vue({
  el: '#app',
  components: { VueMarkdown },
  directives: {
    Foo
  }
})

<template>
<div id="app">
  <vue-markdown :html="true" source="<a href='/foo' v-foo>I have a directive</a>"></vue-markdown>
  // ^output^ <a href="/url" v-foo>I have a directive</a>
  // This <a /> is NOT registered as an element with a directive and NOT logged out.

  <a href="/anotherURL" v-foo>I also have a directive</a> 
  // ^This^ IS registered as an alement with a directive and logged out.
</div>
</template>```