# Precautions
# Abnormal Scenarios in Watch
- Network anomalies, prompt when there is no network.
- Data anomalies (failure to obtain data or backend interface returns an error) handling.
- JS code error handling.
- Prevent duplicate button clicks (especially for operations that send requests upon clicking).
- When the screen turns off and then back on, the onShow lifecycle function will be triggered again. If there is a fetch request in this lifecycle function, it will be initiated again when the screen lights up, so use it with caution.
# Code Specifications
- The code in the app.ux file must be written within
<script></script>tags; otherwise, the code will not execute! - In *.ux files, the
templatenode 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/showwith caution to ensure that the structure of alllist-itemelements remains consistent. - For the
srcattribute ofimage, do not use variable concatenation (e.g.,src="/common/{{type}}"), as the compiler will display warnings during code packaging. It is recommended to use variables directly, likesrc="{{imgPath}}".
# Common Optimizations
- Reduce the number and concurrency of network requests.
- Consider implementing 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 obtain their sizes.
- Use low-resolution network images whenever possible.
- Use pagination for lists, with each page containing no more than 20 items for better performance.
- Do not store network-requested data directly in memory; only store the fields that are needed.
- Use third-party dependencies with caution and opt for lightweight ones.
- Consider placing common code globally to avoid multiple imports.
- Add a loading state to prevent multiple network requests from being initiated due to frequent button clicks.
# Selector Usage Recommendations
For details, see: style documentation
← FAQ