1

I have tried to use marked plugin in my Vue.js apps. Installed [email protected], compiled is nothing problem. But in browser, any contents showed. I used vite to make Vue project. Also, I referred this site.

So my test code like that.

<template>
  <div>
    {{ markdown }}
  </div>
  <div v-html="markdownToHtml"></div>
</template>

<script setup>
import { ref, computed } from "@vue/runtime-core";
import marked from "marked";
const markdown = ref("# hello");
const markdownToHtml = computed(() => {
  return marked(markdown.value);
});
</script>

and error code in console at browser like that.

Uncaught SyntaxError: The requested module '/node_modules/.vite/marked.js?v=f8c9698b' does not provide an export named 'default'

How do I correctly use marked in Vue.js project? Does anyone advise me,please?

2
  • it exports a function so use import { marked } from 'marked'; Commented Jan 6, 2022 at 1:01
  • Thanks for the comments. I really appreciate it! Commented Jan 6, 2022 at 6:10

1 Answer 1

2

You need import the library as

import { marked } from 'marked'

and use like marked.parse(markdown.value)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.