@@ -156,10 +156,13 @@ export default {
156156
157157 watch : {
158158 options : {
159- handler : function ( ) {
160- this . rootContextmenuId = this . getRandomIdWithPrefix ( ) ;
161- this . createInternalOptions ( ) ;
162- this . createPanelOptions ( { options : this . internalOptions } ) ;
159+ handler : function ( val ) {
160+ if ( Array . isArray ( val ) && val . length > 0 ) {
161+ this . rootContextmenuId = this . getRandomIdWithPrefix ( ) ;
162+ this . createInternalOptions ( ) ;
163+ this . createPanelOptions ( { options : this . internalOptions } ) ;
164+ this . addRootContextmenuPanelToBody ( ) ;
165+ }
163166 } ,
164167 immediate : true ,
165168 } ,
@@ -327,14 +330,16 @@ export default {
327330 event . preventDefault ( ) ;
328331 const { rootContextmenuId } = this ;
329332
330- // refresh contextmenu
331- this . resetContextmenu ( ) ;
332- this . showContextmenuPanel ( {
333- event,
334- contextmenuId : rootContextmenuId ,
335- isRootContextmenu : true ,
336- } ) ;
337- this . isPanelsEmptyed = false ;
333+ if ( rootContextmenuId ) {
334+ // refresh contextmenu
335+ this . resetContextmenu ( ) ;
336+ this . showContextmenuPanel ( {
337+ event,
338+ contextmenuId : rootContextmenuId ,
339+ isRootContextmenu : true ,
340+ } ) ;
341+ this . isPanelsEmptyed = false ;
342+ }
338343 } ,
339344
340345 // show contextmenu panel
@@ -507,9 +512,11 @@ export default {
507512
508513 // add root contextmenu panel to body
509514 addRootContextmenuPanelToBody ( ) {
510- this . addContextmenuPanelToBody ( {
511- contextmenuId : this . rootContextmenuId ,
512- } ) ;
515+ if ( this . rootContextmenuId ) {
516+ this . addContextmenuPanelToBody ( {
517+ contextmenuId : this . rootContextmenuId ,
518+ } ) ;
519+ }
513520 } ,
514521
515522 // register contextmenu event
0 commit comments