fix: defineRouteMeta parse 异常

This commit is contained in:
winixt 2022-10-10 16:23:47 +08:00
parent 52c06ff20f
commit b8878c3c24
2 changed files with 9 additions and 3 deletions

View File

@ -71,7 +71,9 @@ function getRouteMeta(content) {
)[0]; )[0];
if (defineRouteExpression) { if (defineRouteExpression) {
const argument = generator(defineRouteExpression.expression.arguments[0]); const argument = generator(defineRouteExpression.expression.arguments[0]);
return JSON.parse(argument.code.replace(/'/g, '"').replace(/(\S+):/g, (global, m1) => `"${m1}":`)); // eslint-disable-next-line no-eval
const fn = eval(`() => (${argument.code})`);
return fn();
} }
} catch (err) {} } catch (err) {}
return null; return null;

View File

@ -6,10 +6,14 @@
</div> </div>
</template> </template>
<script> <script lang="ts">
import { useI18n } from '@fesjs/fes'; import { useI18n, defineRouteMeta } from '@fesjs/fes';
import { FButton } from '@fesjs/fes-design'; import { FButton } from '@fesjs/fes-design';
defineRouteMeta({
'keep-alive': true,
});
export default { export default {
components: { components: {
FButton, FButton,