如何配置 Prism 以使用 Nuxt?我在文件中将其添加为供应商nuxt.config.js
:
// * 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();
}