diff --git a/packages/fes-preset-built-in/src/plugins/route/index.js b/packages/fes-preset-built-in/src/plugins/route/index.js index 11700a53..01d906fa 100644 --- a/packages/fes-preset-built-in/src/plugins/route/index.js +++ b/packages/fes-preset-built-in/src/plugins/route/index.js @@ -117,7 +117,11 @@ const genRoutes = function (parentRoutes, path, parentRoutePath) { if (ext === '.vue') { const { descriptor } = parse(content); const routeMetaBlock = descriptor.customBlocks.find((b) => b.type === 'config'); - routeMeta = routeMetaBlock?.content ? JSON.parse(routeMetaBlock.content) : {}; + try { + routeMeta = routeMetaBlock?.content ? JSON.parse(routeMetaBlock.content) : {}; + } catch (e) { + console.warn(`config: ${routeMetaBlock.content} 必须为 json 格式`); + } if (descriptor.script) { routeMeta = getRouteMeta(descriptor.script.content) || routeMeta; }