不使用 Vue.use 如何在vue页面中使用showdown 插件 ,写出代码示例
时间: 2023-05-21 17:04:12 浏览: 232
可以使用以下代码示例在Vue页面中使用showdown插件,而不需要使用Vue.use:
```html
<template>
<div>
{{convertedText}}
</div>
</template>
<script>
import showdown from 'showdown';
export default {
data() {
return {
text: '# Hello, world!'
}
},
computed: {
convertedText() {
const converter = new showdown.Converter();
return converter.makeHtml(this.text);
}
}
}
</script>
```
在这个示例中,我们将showdown导入为一个模块,并在Vue组件中创建一个computed属性来将文本转换为HTML。这个computed属性依赖于我们使用showdown创建的转换器,该转换器使用makeHtml函数将文本转换为HTML。
阅读全文
相关推荐


















