Markdown Nuxt带有标记,使用自定义函数扩展生成的组件
我一直在尝试使用自定义函数扩展生成的Vue组件 以下是我到目前为止所做的: 在nuxt.config.js中:Markdown Nuxt带有标记,使用自定义函数扩展生成的组件,markdown,nuxt.js,Markdown,Nuxt.js,我一直在尝试使用自定义函数扩展生成的Vue组件 以下是我到目前为止所做的: 在nuxt.config.js中: config.module.rules.push({ test: /\.md$/, include: path.resolve(__dirname, "content"), loader: 'frontmatter-markdown-loader', options: { mode: [FMMode.VUE_COMPONENT],
config.module.rules.push({
test: /\.md$/,
include: path.resolve(__dirname, "content"),
loader: 'frontmatter-markdown-loader',
options: {
mode: [FMMode.VUE_COMPONENT],
vue: {
root: 'markdown' // The class name of the root div
}
}
});
//在我的页面中:
// in asyncData({ params }) :
let post = await import(`~/content/posts/${params.slug}`);
post.vue.component.methods = {
custom_func () {
return 'Processed!'
}
}
return {
post: {
attributes: post.attributes,
component: post.vue.component
}
}
// And in template :
<component :is="post.component" />
理想情况下,我希望在./components/中有一个自定义组件,我在其中注入生成的标记,该标记包含对函数的调用(如{{custom_func(…)}}
),结果将正确显示
我想我离这里很近了(尽管我没有自定义组件),但我不知道Nuxt为什么要将所有内容字符串化
谢谢你的帮助
WARN Cannot stringify a function data 12:23:35
WARN Cannot stringify a function render 12:23:35
WARN Cannot stringify a function created 12:23:35
WARN Cannot stringify a function image_tag 12:23:35
WARN Cannot stringify a function VueComponent