项目中,可能有些组件的复用性非常高,出现的场景也比较多,这时候,一个个页面去引用组件效率就有些低了。
其实我们没有必要在每一个需要的地方使用,而是采取在根组件中注册。根组件中的注册是全局注册。全局注册了之后就可以在根组件下的任何子组件中使用。具体的:
1、准备要全局注册的组件 unshelveTip.vue
<template>
<div class="messageBox">
<el-dialog
title="下架"
width="500px"
:close-on-click-modal="false"
:visible.sync="dialogVisible"
:before-close="handleClose">
<div class="msg">
<h2>确认要下架吗?</h2>
</div>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="">下架并删除</el-button>
<el-button type="primary" @click="">确定</el-button>
<el-button @click="dialogVisible = false">取消