JavaScript 函数 handleQueryNewsId() - 查询新闻 ID 并验证
The function 'handleQueryNewsId' is used to handle the query for a specific news ID.
- The 'loading' variable is set to 'true' to indicate that the query is in progress.
- The 'thisNewsId' variable is assigned the value of 'formData.newsId', which is the inputted news ID.
- The 'getNewsPage' function is called with the parameters 'newsId: thisNewsId', 'page: 1', and 'pageSize: 10' to retrieve the news page with the specified news ID.
- The retrieved data is logged to the console.
- The 'newsIds' variable is assigned an array of news IDs extracted from the retrieved data.
- If the 'newsIds' array includes the 'thisNewsId', it means that the news ID exists. In this case, a message is logged to indicate that the news ID is on sale.
- If the 'newsIds' array does not include the 'thisNewsId', it means that the news ID does not exist. In this case, a message is logged to indicate that the news ID does not exist.
- The 'newsList' variable is assigned the value of 'data.rows', which contains the retrieved news data.
- The 'total' variable is assigned the value of 'data.total', which represents the total number of news pages.
- Finally, the 'loading' variable is set to 'false' to indicate that the query is complete.
原文地址: https://www.cveoy.top/t/topic/ht6U 著作权归作者所有。请勿转载和采集!