mirror of
https://github.com/youzan/vant.git
synced 2025-10-20 02:31:21 +00:00
feat(markdown-loader): compatible with vue 3
This commit is contained in:
@@ -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();
|
||||
|
||||
|
Reference in New Issue
Block a user