在Vue2项目中,可以使用vue-router和webpack来根据不同的路由引入不同的CSS文件。\n\n首先,确保已经安装了vue-router和webpack。\n\n然后,在router/index.js文件中定义路由,并在路由的meta字段中指定要引入的CSS文件。例如:\n\njavascript\nimport Vue from 'vue'\nimport Router from 'vue-router'\nimport Home from '../views/Home.vue'\n\nVue.use(Router)\n\nconst router = new Router({\n mode: 'history',\n routes: [\n {\n path: '/',\n name: 'Home',\n component: Home,\n meta: {\n css: 'home.css' // 指定要引入的CSS文件\n }\n },\n // 其他路由...\n ]\n})\n\nexport default router\n\n\n接下来,在App.vue文件中,通过created钩子函数来动态引入CSS文件。例如:\n\nvue\n<template>\n <div id="app">\n <router-view></router-view>\n </div>\n</template>\n\n<script>\nexport default {\n name: 'App',\n created() {\n const route = this.$route\n if (route.meta.css) {\n const link = document.createElement('link')\n link.rel = 'stylesheet'\n link.href = route.meta.css\n document.head.appendChild(link)\n }\n }\n}\n</script>\n\n\n这样,在每次路由切换时,都会根据当前路由的meta字段动态引入对应的CSS文件。\n\n请注意,上述代码只是示例,具体的CSS文件路径和引入方式需要根据项目实际情况进行调整。