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

Using VueMarkdown in main.js #61

Open Aleksey-Danchin opened 6 years ago

Aleksey-Danchin commented 6 years ago

Your live editor http://miaolz123.github.io/vue-markdown/ don't support katex syntax.

What is rong with vue-markdown? Why I can't in main.js file just "use" it's once?

// main.js from vue-cli webpack start source
import Vue from 'vue'
import VueMarkdown from 'vue-markdown'
Vue.use(VueMarkdown)

... and in the one of components use <vue-markdown></vue-markdown>. Insted the warm: [Vue warn]: Unknown custom element: <vue-markdown> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

Everytime in each component where needed markdown I import vue-component again, and declare

// component.vue
import VueMarkdown from 'vue-markdown'

export default {
    name: 'EducationMaterialInstance',
    components: { VueMarkdown },
    ...

I tried to work with VueMarkdown as with all the other modules. With VueMarkdown it does not work. Do I not understand something? How correctly installation of Vue Markdown?

Lsnsh commented 6 years ago

Register the VueMarkdown component as a global component.

// main.js
import Vue from 'vue';
import VueMarkdown from 'vue-markdown';

Vue.component('vue-markdown', VueMarkdown);
// App.vue
<template>
  <section class="container">
    <vue-markdown>i am a ~~tast~~ **test**.</vue-markdown>
  </section>
</template>
...
Dynamic-Gravity commented 6 years ago

@Lsnsh This worked for me, thanks!

mtwolak commented 4 years ago

You should close this issue, it's resolved.