Nuxt.js 页面源代码格式化输出:使用 vue-beautify 插件
可以使用'vue-beautify'插件来对页面源代码进行格式化输出,具体步骤如下:
- 安装'vue-beautify'插件
npm install vue-beautify --save-dev
- 在'nuxt.config.js'中配置插件
module.exports = {
// ...
build: {
extend(config, { isDev, isClient }) {
if (isDev && isClient) {
// ...
config.module.rules.push({
test: /.(vue|js|jsx)$/,
loader: 'vue-beautify-loader',
enforce: 'pre',
exclude: /(node_modules)/
})
}
}
}
}
- 在开发环境下重新启动项目
npm run dev
现在,在浏览器中打开页面后,可以在开发者工具中看到经过格式化输出的源代码。
原文地址: https://www.cveoy.top/t/topic/lTPp 著作权归作者所有。请勿转载和采集!