From 3c4ac57d600d84af76194e8795ece0a11b9d70d7 Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Thu, 19 Oct 2023 10:03:23 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20getElementById=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=B3=9B=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/get-element-by-id/get-element-by-id.uvue | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pages/API/get-element-by-id/get-element-by-id.uvue b/pages/API/get-element-by-id/get-element-by-id.uvue index 6975757b..4ef31ce3 100644 --- a/pages/API/get-element-by-id/get-element-by-id.uvue +++ b/pages/API/get-element-by-id/get-element-by-id.uvue @@ -41,10 +41,12 @@ export default { text.style.setProperty('color', 'red') }, changeViewStyle(){ - const view = uni.getElementById('view')! - view.style.setProperty('width', '90%') - view.style.setProperty('height', '50px') - view.style.setProperty('backgroundColor', '#007AFF') + const view = uni.getElementById('view') + if(view !== null){ + view.style.setProperty('width', '90%') + view.style.setProperty('height', '50px') + view.style.setProperty('backgroundColor', '#007AFF') + } } } } -- GitLab