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

使用useForm的setProps设置表单的 props 参数schemas时,根据一个判断值切换会不更新页面,会一直以第二次设置的为准 #688

Closed
3 tasks
IFnGSiYu opened this issue Jun 1, 2021 · 10 comments
Labels
bug Something isn't working

Comments

@IFnGSiYu
Copy link

IFnGSiYu commented Jun 1, 2021

⚠️ IMPORTANT ⚠️ Please check the following list before proceeding. If you ignore this issue template, your issue will be directly closed.

  • Read the docs.
  • Make sure the code is up to date. (Some bugs have been fixed in the latest code)
  • This is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.

Describe the bug

A clear and concise description of what the bug is..

Reproduction

Please describe the steps of the problem in detail to ensure that we can restore the correct problem

System Info

  • Operating System:
  • Node version:
  • Package manager (npm/yarn/pnpm) and version:
@IFnGSiYu
Copy link
Author

IFnGSiYu commented Jun 1, 2021

if (modelType.value === 3) {
console.log('重置密码');
setProps({ schemas: resetPsdformSchema});
} else {
setProps({ schemas: accountFormSchema })
}
这样设置,是我用的方法不对,还是一个bug

@anncwb
Copy link
Collaborator

anncwb commented Jun 1, 2021

这个可以直接使用一个computed,传入Form组件即可

const getSchemas=computed(()=>{
return modelType.value === 3? resetPsdformSchema: accountFormSchema
})

<Form schemas="getSchemas"></Form>

@IFnGSiYu
Copy link
Author

IFnGSiYu commented Jun 2, 2021

我昨天描述问题没说好,问题应该是动态设置schemas 后,再updateSchema更新会造成视图不会更新

@mynetfan
Copy link
Collaborator

mynetfan commented Jun 3, 2021

未能重现问题。
image
测试如图代码可正常工作。

@anncwb
Copy link
Collaborator

anncwb commented Jun 3, 2021

Hello @IFnGSiYu. Please provide the complete reproduction steps and code. Issues labeled by need reproduction will be closed if no activities in 3 days.

@IFnGSiYu
Copy link
Author

IFnGSiYu commented Jun 3, 2021

这样设置不同的schemas
if (modelType.value === 3) {
console.log('重置密码');
setProps({ schemas: resetPsdformSchema});
} else {
setProps({ schemas: accountFormSchema })
}
然后updateSchema会出现问题

@mynetfan
Copy link
Collaborator

mynetfan commented Jun 3, 2021

你给的代码片段不足以重现问题,请提供足够的可以重现问题的演示代码。我再加一个onBtn2Click设置schemas2也没能出现问题。

@mynetfan
Copy link
Collaborator

mynetfan commented Jun 3, 2021

已找到问题。

@mynetfan mynetfan added bug Something isn't working and removed needs reproduction labels Jun 3, 2021
@IFnGSiYu
Copy link
Author

IFnGSiYu commented Jun 3, 2021

期待解决方案

@noahlann
Copy link

noahlann commented Sep 3, 2021

model 其实也会出现这个问题,最后我直接放到了 template 内 ,使用useForm()会出现这个问题,目测是响应性的问题。。。(但是我看内部具有对 props 的整体watch,当formDataRef变更时,这个watch并没有被触发【P.s有时候莫名其妙就好了。。】)

@github-actions github-actions bot locked and limited conversation to collaborators Sep 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants