提交 4f474504 编写于 作者: View Design's avatar View Design

Update ProsePre.global.vue

上级 62e14af6
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
/> />
</pre> </pre>
<UDivider :ui="{ border: { base: 'border-gray-700' } }" /> <UDivider :ui="{ border: { base: 'border-gray-700' } }" />
<pre :class="$props.class" class="m-0 rounded-tl-none rounded-tr-none"><code ref="codeBlock">{{ code }}</code></pre> <pre :class="$props.class" class="m-0 rounded-tl-none rounded-tr-none"><code v-html="codeBlock"></code></pre>
</template> </template>
<script setup> <script setup>
...@@ -55,9 +55,9 @@ const handleCopy = () => { ...@@ -55,9 +55,9 @@ const handleCopy = () => {
} }
const codeBlock = ref(null) const codeBlock = ref(null)
const handleRender = () => { const handleRender = () => {
if (codeBlock.value) { if (props.language) {
codeBlock.value.textContent = props.code const lang = props.language === 'vue' ? 'html' : props.language
hljs.highlightElement(codeBlock.value) codeBlock.value = hljs.highlight(lang, props.code, true).value
} }
} }
watch(()=> props.code, () => { watch(()=> props.code, () => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册