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

extra 设置表单扩展提示信息,用于字段说明 #154

Open
suibansheng opened this issue Apr 15, 2024 · 1 comment
Open

extra 设置表单扩展提示信息,用于字段说明 #154

suibansheng opened this issue Apr 15, 2024 · 1 comment

Comments

@suibansheng
Copy link

extra 说明是 根据 record 动态生成说明,有没有操作方式

Copy link

dosubot bot commented Apr 15, 2024

To dynamically generate the extra property for form extension hints based on record data, you can use a computed property in Vue. Here's a concise guide:

  1. Access Record Data: Make sure the record data is accessible in your component, either directly or through injection.

  2. Create a Computed Property: Define a computed property that generates the hint based on the record data. This ensures the hint updates automatically with data changes.

  3. Bind the Computed Property: Use this computed property as the value for the extra property in your form item component.

Example implementation:

<script setup>
import { computed, inject } from 'vue'

const formModel = inject('formModel') // Accessing the record data

const dynamicHint = computed(() => {
  const fieldValue = formModel.value.someField // Customize to access the correct field
  return `Current value is: ${fieldValue}` // Customize the hint message
})
</script>

In your template, bind dynamicHint to the extra property of the form item:

<ma-form-item :extra="dynamicHint.value">

Ensure your ma-form-item component can accept and properly handle the extra prop, passing it down to the underlying form item component it wraps. If ma-form-item is a custom component, you might need to modify it to support this functionality.

Sources

About Dosu

This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant