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 @@ -84,7 +84,7 @@
shadow="never"
style="max-height: 350px; overflow: scroll"
>
{{ result || '-' }}
{{ String(result) == '0' ? 0 : result || '-' }}
</el-card>
</div>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

The code has no immediate logical errors but can be improved and optimized:

  1. Use Template Literals: The use of single quotes for strings inside the template expression {{ result || '-' }} is unnecessary when you're using the .toString() function later on in the same expression.

  2. Boolean Check: The use of strict equality (===) with '0' is redundant because it will return false even if result is a number that equals zero (e.g., 0, -0). A simple check with loose equality (==) suffices.

  3. Code Readability: While minor, using descriptive variable names could improve readability, such as changing result to something like responseData.

Here’s an updated version of the code:

<div class="card-container">
  <vue-custom-scrollbar max-height="350px" overflow-y-scroll>
    <el-card :shadow="'never'" :style="{ maxHeight: '350px', overflowY: 'scroll' }">
      {{ Number(responseData) === 0 ? 0 : responseData || '-' }}
    </el-card>
  </vue-custom-scrollbar>
</div>

This change ensures better JavaScript logic and improves readability while maintaining functionality.

Expand Down