vue全局混入template方法:在根目录vue.config.js(没有就新增)里添加一下代码
//红色部分是混入的自定义vue组件
module.exports = { chainWebpack: config => { config.module.rule('vue').use('vue-loader').loader('vue-loader').tap(options => { const compile = options.compiler.compile options.compiler.compile = (template, ...args) => { if (args[0].resourcePath.match(/^pages/)) { template = template.replace(/[\s\S]+?<[\d\D]+?>/, _ => `${_} <updagrade ref="updagrade" />`) } return compile(template, ...args) } return options }) } }
标签:uniapp,混入,vue,loader,compile,template,options From: https://www.cnblogs.com/itsone/p/17843633.html