// 定义要忽略的警告关键词列表 const ignoredWarnings = [ // '`markRaw` or using `shallowRef` instead of `ref`', ] /** 忽略组件响应式警告 */ export default function (app) { // 只忽略组件响应式警告 app.config.warnHandler = (msg, instance, trace) => { // 检查是否包含要忽略的关键词 const shouldIgnore = ignoredWarnings.some(warning => msg.includes(warning) ) // 如果不应该忽略,才输出警告 if (!shouldIgnore) { console.warn(msg, instance, trace) } } }