gpt4 book ai didi

node.js - 如何使用 Nuxt 配置 Prism

转载 作者:行者123 更新时间:2023-12-03 12:15:26 25 4
gpt4 key购买 nike

如何配置 Prism 以与 Nuxt 一起使用?我在 nuxt.config.js 中将其添加为 vendor 文件:

// * Build configuration

build: {
// * You can extend webpack config here
vendor: ['axios', 'prismjs'],

extend(config, ctx) {
if (ctx.isServer) {
config.externals = [
nodeExternals({
whitelist: [/^vuetify/]
})
];
}
}
}

然后在我的页面的脚本部分导入它:
<script>
import Prism from'prismjs';

export default {
data() {
return {
post: {}
};
},
// more data...

那我怎么用呢?我试过在mounted中调用它,但它不起作用。不会返回任何错误,但不会在现场更改任何内容。
mounted() {
Prism.highlightAll();
}

最佳答案

原来是工作,只是忘了包括 css 样式。

关于node.js - 如何使用 Nuxt 配置 Prism,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52283175/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com