Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dsl-page):修复本地运行中对于props属性引用utils出码报错的问题 #346

Merged
merged 2 commits into from
Apr 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/vue-generator/src/generator/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,15 @@ function handleBinding(props, attrsArr, description, state) {
return attrsArr.push(`v-model${modelArgs}="${item.value.replace(/this\.(props\.)?/g, '')}"`)
}

// 弥补在recurseChildren方法中,当children为undefined,但是该元素的props存在变量绑定的情况,此变量绑定的为
// 当前JSResources在props的使用场景为变量绑定,使用范式一般为:this.xxx
const pickResourceKeys = item.value?.match(/(?<=this\.)\w+/g) || []
const itemObject = Object.fromEntries(pickResourceKeys.map((key) => [key, true]))

Object.keys(description.jsResource).forEach((jsResourceKey) => {
description.jsResource[jsResourceKey] = description.jsResource[jsResourceKey] || itemObject[jsResourceKey]
})

// expression 使用 v-bind 绑定
return attrsArr.push(`:${key}="${item.value.replace(/this\.(props\.)?/g, '')}"`)
}
Expand Down
Loading