feat(markdown-loader): compatible with vue 3

This commit is contained in:
chenjiahan
2020-05-28 14:49:14 +08:00
parent 6abb2fc081
commit d697026b2c
4 changed files with 17 additions and 19 deletions

View File

@@ -12,16 +12,11 @@ function wrapper(content) {
content = escape(content);
return `
<template>
<section v-html="content" v-once />
</template>
import { h } from 'vue';
const content = unescape(\`${content}\`);
<script>
export default {
created() {
this.content = unescape(\`${content}\`);
},
mounted() {
const anchors = [].slice.call(this.$el.querySelectorAll('h2, h3, h4, h5'));
@@ -39,9 +34,12 @@ export default {
})
}
}
},
render() {
return h('section', { innerHTML: content });
}
};
</script>
`;
}
@@ -53,7 +51,7 @@ const parser = new MarkdownIt({
slugify,
});
module.exports = function(source) {
module.exports = function (source) {
let options = loaderUtils.getOptions(this) || {};
this.cacheable && this.cacheable();