如何从VUE 3插件创建NUXT 3插件? (vue3-markdown-it)
我是NUXT的新手,并且正在尝试将VUE插件vue3-markdown-it
转换为NUXT 3插件,但是正在收到以下错误:
[VUE WARN]:未能解决:组件:MARKDOWN如果这是本机自定义元素,请确保通过CompilerOptions.iscustomelement.
将其排除在组件分辨率中
。
// md-plugin.client.ts
import Markdown from 'vue3-markdown-it'
export default defineNuxtPlugin(nuxtApp => {
nuxtApp.vueApp.use(Markdown)
})
// index.vue
<template>
<main>
<ClientOnly>
<Markdown :source="content" />
</ClientOnly>
</main>
</template>
<script lang="ts" setup>
const { find } = useStrapi4()
const {
data: {
attributes: { content },
},
} = await find('homepage')
</script>
I am new to Nuxt, and am attempting to turn the Vue plugin vue3-markdown-it
into a Nuxt 3 plugin, but am receiving the following error:
[Vue warn]: Failed to resolve component: Markdown If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.
What am I doing incorrectly?
// md-plugin.client.ts
import Markdown from 'vue3-markdown-it'
export default defineNuxtPlugin(nuxtApp => {
nuxtApp.vueApp.use(Markdown)
})
// index.vue
<template>
<main>
<ClientOnly>
<Markdown :source="content" />
</ClientOnly>
</main>
</template>
<script lang="ts" setup>
const { find } = useStrapi4()
const {
data: {
attributes: { content },
},
} = await find('homepage')
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在不同的插件上也有类似的问题。我通过使用组件而不是插件解决了问题。
在组件文件夹(markdown.vue)下创建一个新文件。
在此文件中添加标记代码:
您可以自定义此代码。
删除插件文件(md-plugin.client.ts)
现在
&lt; markdown:source =“ content”/&gt;
将看到我们生成的 markdown component。它奏效了。I had a similar problem on different plugin. I solved the problem by using component instead of plugin.
Create a new file under the components folder (Markdown.vue).
Add Markdown codes in this file:
You can customize this code.
Delete plugin file (md-plugin.client.ts)
Now
<Markdown :source="content" />
will see our generated Markdown component. It worked me.