mirror of
https://gitee.com/newgateway/vtj.git
synced 2026-06-23 19:53:25 +08:00
- 增加 dayjs 和 dateFormat 的核心API说明及使用示例 - 说明在组件中如何使用 @vtj/utils 导出的日期处理工具 - 调整后续章节编号,新增“日期处理”章节为第十三章 - 明确 @vtj/utils 中 dayjs 已默认配置中文 locale,简化使用说明 parser(fixer): 支持跳过动态绑定的 name 属性避免误替换 - 在处理 vant-icon name 属性时,跳过包含 :name 或 v-bind:name 的动态绑定情况 parser(vue): 增强 parseTemplate 返回context,支持上下文变量替换 - parseTemplate 函数返回值中新增 context 字段 - 在 compositionPatch 处理中,将 v-for 和 slot 上下文变量等替换为 this.context.xxx 访问形式 parser(tests): 补充 Composition API 模式下 v-for 和 slot 上下文变量转换测试 - 新增测试覆盖 vant-icon 动态 name 属性转换为 this.context.xxx - 测试 v-for 中上下文变量转换为 this.context.xxx - 测试 slot 作用域变量转换为 this.context.xxx parser(utils): 清理移除旧的复杂 replacer 函数及相关注释 - 删除无用代码,减小包体积,提高可维护性 test(debug): 新增调试用例打印 v-for 中 card.user 的节点转换结果
37 lines
893 B
TypeScript
37 lines
893 B
TypeScript
import { expect, test } from 'vitest';
|
|
import { parseVue } from '../src';
|
|
|
|
const project = { apis: [], dependencies: [] } as any;
|
|
|
|
const cardSource = `
|
|
<template>
|
|
<div v-for="(card, index) in cardList" :key="index">
|
|
<VanIcon :name="card.user" size="24" color="#fff"></VanIcon>
|
|
</div>
|
|
</template>
|
|
<script lang="ts" setup>
|
|
// @ts-nocheck
|
|
import { useProvider } from '@vtj/renderer';
|
|
import { ref } from 'vue';
|
|
import { Icon as VanIcon } from 'vant';
|
|
|
|
const __provider = useProvider({ id: '1l2qoifa', version: '1781539187917' });
|
|
|
|
const cardList = ref([{ icon: 'contact' }])
|
|
</script>
|
|
<style lang="css" scoped>
|
|
/* 组件样式内容 */
|
|
</style>
|
|
`;
|
|
|
|
test('debug card.user', async () => {
|
|
const result = await parseVue({
|
|
project,
|
|
id: '1l2qoifa',
|
|
name: 'CardDemo',
|
|
source: cardSource
|
|
});
|
|
|
|
console.log('NODES:', JSON.stringify(result.nodes, null, 2));
|
|
});
|