Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click.prevent="dialogVisible = false"> {{ $t('common.cancel') }} </el-button>
<el-button @click.prevent="close"> {{ $t('common.cancel') }} </el-button>
<el-button type="primary" @click="submit(fieldFormRef)" :loading="loading">
{{ isEdit ? $t('common.save') : $t('common.add') }}
</el-button>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks mostly correct with some general tips:

  1. Function Name: The close function in the template should be defined somewhere before it's called.

  2. Loading Property: Ensure that the $ref('fieldFormRef').loading property exists in the Vue component lifecycle to avoid potential null/undefined errors.

  3. Translation Strings: Make sure the $t() method returns the expected translations for "common.cancel", "common.save", and "common.add".

Here is an example of how you might define such functions in a Vue component:

<template>
  <!-- Your existing template -->
</template>

<script>
export default {
  data() {
    return {
      loading: false,
    };
  },
  methods: {
    submit(form) {
      // Submission logic here
      this.loading = true;
      setTimeout(() => {
        this.loading = false;
        // Success callback here
        alert("Submission successful");
      }, 1000);
    },
    close() {
      this.dialogVisible = false; // Assuming dialogVisible is managed by state
    },
  },
};
</script>

This ensures that all components used correctly within your application are available and properly initialized in runtime environments. Additionally, managing component references and lifecycle hooks efficiently can prevent unexpected behavior due to changes or updates between renders/components during development/testing. Let me know if you need further clarification on these points!

Expand Down
Loading