Step 1
Create a pop-up page, we name the page dialogComponent, and the following content should be set in the pop-up page:
<template> <!--1.first,There should be a pop-up pageel-dialogComponents are pop-up components,We put the contents in the pop-up windowel-dialogIn the component--> <!--2.set up:property,Dynamically bind a boolean value,通过这个property来控制弹窗是否弹出--> <el-dialog title="Popular window" :="detailVisible" width="35%"> Pop-up content </el-dialog> </template> <script> export default { name: "dialogComponent", data(){ return{ detailVisible:false } }, methods:{ //3. Define an init function, and make the pop-up pop-up by setting the detailedVisible value to true. This function will be called in the parent component's method. init(data){ =true; //data is the value passed by the pop-up window of the parent component. We can print it and see (data); } } } </script>
Step 2
Introduce pop-up components into the parent component and pop-ups are pop-ups by clicking on events. The parent component mainly sets the following contents:
<template> <!-- 6.Define a click event--> <button @click="handleClick('Parent Component')">Click</button> <!-- 3.Use in the pagedialog-componentComponents--> <!-- 4.set upv-ifStatement,Change dynamicallyVisiableValues are used to control whether pop-up windows pop up--> <!-- 5.set uprefproperty,Equivalent to a unique identifierdialog-componentComponents--> <dialog-component v-if="Visiable" ref="dialog"></dialog-component> </template> <script> // 1.Introduce pop-up component dialogComponentimport dialogComponent from "./dialogComponent"; export default { // 2. Register the dialogComponent component in components components:{ dialogComponent }, data(){ return{ Visible:false } }, methods:{ // 7. To realize click events, click events must include the following content handleClick(data){ =true; this.$nextTick(()=>{ //The dialog here is consistent with the ref attribute value in the dialog-component component above. //Init calls the init method in the dialog-component component //data is the value passed to the pop-up page this.$(data); }) }, } } </script>
Note: The vue component uses camel name when defining, but it should be converted into short horizontal line name when used!
Summarize
This is the article about how vue pop-up page pop-up page is introduced here. For more related contents of vue pop-up pages, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!