javascript - How does Vue2.x dynamically insert a message prompt component after conditional judgment
仅有的幸福
仅有的幸福 2017-05-19 10:25:11
0
2
689

I originally used Message in Element UI, but the style did not match the project, and the design was given to a new UI. Now I want to write this message prompt as a component. How to implement this call Message.error('Interface request fail');. Or it doesn’t have to be in this form, as long as it can be dynamically inserted into the DOM

after being called in api.js
仅有的幸福
仅有的幸福

reply all(2)
PHPzhong

I have tried two methods
One: hang the component to the root component and bind the component's status information to vuex. Expose an interface in the prototype of vue to change the status of the component. That is, change vuex by calling dispatch Status thus causing the component status to change.

2. The component does not need to be mounted, but exposes an interface in the vue prototype. Whenever the interface is called, a vue instance is dynamically constructed and the Message component is used as its subcomponent

伊谢尔伦

You can write a pop-up component, reference vuex and set a variable globally. When ajax returns, the pop-up box will be displayed according to different states

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template