forked from opentiny/tiny-engine
fix: slot params missing double quote (#605)
* fix: slot params missing double quote * fix: exclude nodemodule test case
This commit is contained in:
parent
91d3ae108c
commit
e651dffa2b
|
|
@ -229,7 +229,7 @@ export const handleSlotBindAttrHook = (schemaData) => {
|
|||
let paramsValue = ''
|
||||
|
||||
if (Array.isArray(params)) {
|
||||
paramsValue = `={ ${params.join(',')} }`
|
||||
paramsValue = `="{ ${params.join(',')} }"`
|
||||
} else if (typeof params === 'string') {
|
||||
paramsValue = `="${params}"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
import { expect, test } from 'vitest'
|
||||
import { genSFCWithDefaultPlugin } from '@/generator/vue/sfc'
|
||||
import schema from './page.schema.json'
|
||||
import componentsMap from './components-map.json'
|
||||
import { formatCode } from '@/utils/formatCode'
|
||||
|
||||
test('should generate slot declaration correctly', async () => {
|
||||
const res = genSFCWithDefaultPlugin(schema, componentsMap)
|
||||
const formattedCode = formatCode(res, 'vue')
|
||||
|
||||
await expect(formattedCode).toMatchFileSnapshot('./expected/slotTest.vue')
|
||||
})
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
[
|
||||
{
|
||||
"componentName": "TinyTree",
|
||||
"exportName": "Tree",
|
||||
"package": "@opentiny/vue",
|
||||
"version": "^3.10.0",
|
||||
"destructuring": true
|
||||
}
|
||||
]
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
<template>
|
||||
<div>
|
||||
<tiny-tree
|
||||
:data="[
|
||||
{ label: '一级 1', children: [{ label: '二级 1-1', children: [{ label: '三级 1-1-1' }] }] },
|
||||
{
|
||||
label: '一级 2',
|
||||
children: [
|
||||
{ label: '二级 2-1', children: [{ label: '三级 2-1-1' }] },
|
||||
{ label: '二级 2-2', children: [{ label: '三级 2-2-1' }] }
|
||||
]
|
||||
}
|
||||
]"
|
||||
>
|
||||
<template #default="{ data }">
|
||||
<span>{{ data.label }}</span></template
|
||||
></tiny-tree
|
||||
>
|
||||
<tiny-tree
|
||||
:data="[
|
||||
{ label: '一级 1', children: [{ label: '二级 1-1', children: [{ label: '三级 1-1-1' }] }] },
|
||||
{
|
||||
label: '一级 2',
|
||||
children: [
|
||||
{ label: '二级 2-1', children: [{ label: '三级 2-1-1' }] },
|
||||
{ label: '二级 2-2', children: [{ label: '三级 2-2-1' }] }
|
||||
]
|
||||
}
|
||||
]"
|
||||
>
|
||||
<template #default="data">
|
||||
<span>{{ data.label }}</span></template
|
||||
></tiny-tree
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { Tree as TinyTree } from '@opentiny/vue'
|
||||
import * as vue from 'vue'
|
||||
import { defineProps, defineEmits } from 'vue'
|
||||
import { I18nInjectionKey } from 'vue-i18n'
|
||||
|
||||
const props = defineProps({})
|
||||
|
||||
const emit = defineEmits([])
|
||||
const { t, lowcodeWrap, stores } = vue.inject(I18nInjectionKey).lowcode()
|
||||
const wrap = lowcodeWrap(props, { emit })
|
||||
wrap({ stores })
|
||||
|
||||
const state = vue.reactive({})
|
||||
wrap({ state })
|
||||
</script>
|
||||
<style scoped></style>
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
{
|
||||
"state": {},
|
||||
"methods": {},
|
||||
"componentName": "Page",
|
||||
"fileName": "createVm",
|
||||
"css": "",
|
||||
"props": {},
|
||||
"lifeCycles": {},
|
||||
"children": [
|
||||
{
|
||||
"componentName": "TinyTree",
|
||||
"props": {
|
||||
"data": [
|
||||
{
|
||||
"label": "一级 1",
|
||||
"children": [
|
||||
{
|
||||
"label": "二级 1-1",
|
||||
"children": [
|
||||
{
|
||||
"label": "三级 1-1-1"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "一级 2",
|
||||
"children": [
|
||||
{
|
||||
"label": "二级 2-1",
|
||||
"children": [
|
||||
{
|
||||
"label": "三级 2-1-1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "二级 2-2",
|
||||
"children": [
|
||||
{
|
||||
"label": "三级 2-2-1"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"id": "33f52342",
|
||||
"children": [
|
||||
{
|
||||
"componentName": "Template",
|
||||
"props": {
|
||||
"slot": {
|
||||
"name": "default",
|
||||
"params": ["data"]
|
||||
}
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"componentName": "Text",
|
||||
"props": {
|
||||
"text": {
|
||||
"type": "JSExpression",
|
||||
"value": "data.label"
|
||||
}
|
||||
},
|
||||
"id": "c225d165"
|
||||
}
|
||||
],
|
||||
"id": "415d5f65"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"componentName": "TinyTree",
|
||||
"props": {
|
||||
"data": [
|
||||
{
|
||||
"label": "一级 1",
|
||||
"children": [
|
||||
{
|
||||
"label": "二级 1-1",
|
||||
"children": [
|
||||
{
|
||||
"label": "三级 1-1-1"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "一级 2",
|
||||
"children": [
|
||||
{
|
||||
"label": "二级 2-1",
|
||||
"children": [
|
||||
{
|
||||
"label": "三级 2-1-1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "二级 2-2",
|
||||
"children": [
|
||||
{
|
||||
"label": "三级 2-2-1"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"id": "33f52342",
|
||||
"children": [
|
||||
{
|
||||
"componentName": "Template",
|
||||
"props": {
|
||||
"slot": {
|
||||
"name": "default",
|
||||
"params": "data"
|
||||
}
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"componentName": "Text",
|
||||
"props": {
|
||||
"text": {
|
||||
"type": "JSExpression",
|
||||
"value": "data.label"
|
||||
}
|
||||
},
|
||||
"id": "c225d165"
|
||||
}
|
||||
],
|
||||
"id": "415d5f65"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -17,7 +17,7 @@ import { viteStaticCopy } from 'vite-plugin-static-copy'
|
|||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
test: {
|
||||
exclude: ['**/result/**'],
|
||||
exclude: ['**/result/**', 'node_modules'],
|
||||
watchExclude: ['**/result/**']
|
||||
},
|
||||
resolve: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue