# Precautions
# Exception Scenarios in the Watch
- Network exceptions, prompt when there is no network
- Data exceptions (no data is obtained, or the backend interface returns an error)
- JS code error handling
- Prevent duplicate clicks on buttons (especially pay attention to operations that send requests after clicking)
- When the screen turns off and then back on, the onReady and onShow lifecycle functions will be triggered again
# Code Specifications
- The code in the app.ux file must be written within
<script></script>
, otherwise the code will not execute! - In *.ux files, the
template
node can only have one root node - CSS properties related to angles must include units, such as
total-angle: 360deg
- In
list-item
, use conditional judgments likeif
/else
/show
cautiously to ensure alllist-item
structures are consistent - For the
src
attribute ofimage
, do not use variable concatenation (e.g.,src="/common/{{type}}"
), otherwise the compiler will display a warning during packaging. It is recommended to use the variable directly, likesrc="{{imgPath}}"
# Common Optimizations
- Reduce the number of network requests and concurrency
- Consider local caching for interfaces with low real-time data requirements (also consider data size for caching)
- Control the number of local files and avoid directly traversing files to get all file sizes
- Use low-resolution network images whenever possible
- Use pagination for lists, with about 20 items per page being optimal
- Do not store network request data directly in memory; only store the fields that are needed
- Use third-party dependencies cautiously and prefer lightweight ones
- Consider placing common code in the global scope to avoid multiple imports
- Add a loading state to prevent multiple network requests from being initiated due to frequent button clicks
← FAQ