[Vuejs]-How to convert markdown img to vue component in Vue3?

0👍

VuePress 2 and VitePress both allow you to use Vue 3 components directly in Markdown files.

Example markdown with Vue SFC:

[Home](../README.md)
[About](../about/README.md)

_Hello world_

<img @click="showModal = true" :src="imgUrl">
<MyModal v-if="showModal" />

<script>
import { ref } from 'vue'
import MyModal from '@/components/MyModal.vue'

export default {
  components: {
    MyModal
  },
  setup() {
    return {
      showModal: ref(false),
      imgUrl: 'path/to/image'
    }
  }
}
</script>

Leave a comment