vue项目开发中,如何生成sitemap.xml
文件,下面web建站小编给大家简单介绍一下!
在router.js路由中新增以下代码:
function getRoutesList(routes, pre) { return routes.reduce((array, route) => { const path = `${pre}${route.path}`; if (route.path !== '*') { array.push(path); } if (route.children) { array.push(...getRoutesList(route.children, `${path}/`)); } return array; }, []); } //生成sitemap function getRoutesXML() { const list = getRoutesList(router.options.routes, 'https://ipkd.cn/') .map(route => `<url><loc>${route}</loc></url>`) .join('\r\n'); return `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"> ${list} </urlset>`; } console.log('输出sitemap:', getRoutesXML())
vue项目开发中一般会出现哪些报错?(vue常见的10种错误)
上面是“vue项目中如何生成sitemap.xml文件”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_4787.html
workflows工作流
王家卫电视剧繁花海报效果comfyui工作流
一架令人难忘的美丽钢琴ComfyUI工作流
1个粉红色头发可爱的女孩ComfyUI工作流
荷塘月色ComfyUI工作流
一个纸杯蛋糕ComfyUI工作流
一碗热气腾腾的拉面ComfyUI工作流
一辆停在混凝土墙前运动型SUV捷豹概念车
一种长着彩虹翅膀的虫子comfyui工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!