简体   繁体   中英

Open a modal of vue-js-modal from outside a component

We are using vue-js-modal in our project, and I want to open a modal from code which isn't in a vue component. The documentation only indicate how to use the API from a component. There is a way to manipulate vue-js-modal from anywhere?

The X problem, I want to warn user with a popup when a router error occure in router.onError((error)=>...)

Instantiating a new Vue object, allow to acces the $modal API entrypoint:

const vue = new Vue();
vue.$modal.show({template:'<div>Error during loading...</div>'});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM