File tree Expand file tree Collapse file tree 2 files changed +3
-18
lines changed
packages/uni-app-plus/src/x Expand file tree Collapse file tree 2 files changed +3
-18
lines changed Original file line number Diff line number Diff line change @@ -5,16 +5,10 @@ import { getCurrentPage } from '@dcloudio/uni-core'
55export const getElementById = defineSyncApi < GetElementById > (
66 'getElementById' ,
77 ( id : string . IDString | string ) : UniElement | null => {
8- const page = ( getCurrentPage ( ) as unknown as UniPage ) . vm
8+ const page = getCurrentPage ( ) as unknown as UniPage
99 if ( page == null ) {
1010 return null
1111 }
12-
13- const bodyNode = page . $el ?. parentNode
14- if ( bodyNode == null ) {
15- console . warn ( 'bodyNode is null' )
16- return null
17- }
18- return bodyNode . querySelector ( `#${ id } ` )
12+ return page . getElementById ( id )
1913 }
2014)
Original file line number Diff line number Diff line change @@ -50,16 +50,7 @@ export function setupXPage(
5050 return new UTSJSONObject ( pageVm . $basePage . options )
5151 } ,
5252 } )
53- uniPage . getElementById = (
54- id : string . IDString | string
55- ) : UniElement | null => {
56- const containerNode = pageVm . $el ?. parentElement
57- if ( containerNode == null ) {
58- console . warn ( 'bodyNode is null' )
59- return null
60- }
61- return containerNode . querySelector ( `#${ id } ` )
62- }
53+
6354 uniPage . vm = pageVm
6455 uniPage . $vm = pageVm
6556
You can’t perform that action at this time.
0 commit comments