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工作流
严寒的冬天里一只小鸟在森林的树枝上休息
一只穿着黑色蝴蝶结西装可爱橙色小猫
一头巨大的古代大象背后建着一座城市
一条精致透明的朱红色水晶龙
一颗巨型的木星ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

iframe开发admin后台
黑客入侵效果代码
纯css翻书效果
利用CSS3做一个星级评分样式
barcode条形码/qrcode二维码兼容所有浏览器(含ie6/ie7/ie8)
css3做一个风雨雷电天气动态图标
会议人员60s签到倒计时插件
canvas黑洞漩涡(canvas+js)













