vue组件之Alert的实现代码

前言

本文主要Alert 组件的大致框架, 提供少量可配置选项。 旨在大致提供思路

Alert

用于页面中展示重要的提示信息。

templat模板结构

rush:xhtml;">

大致结构 alert框,icon图标, slot插值 (其他样式颜色选项...)

如果需要动画 可以在外层包上Vue内置组件transition

rush:xhtml;">

script

rush:js;"> export default { name: 'Alert',props: { closable: { type: Boolean,default: true },show: { type: Boolean,default: true,twoWay: true },type: { type: String,default: 'info' } },data() { return { visible: this.show }; },methods: { close() { this.visible = false; this.$emit('update:show',false); this.$emit('close'); } } };

点击关闭 向外暴露2个事件

使用

rush:js;"> import Alert from './Alert.vue'

Alert.install = function(Vue){
Vue.component('Alert',Alert);
}
export default Alert

rush:xhtml;"> 一个不能关闭的alert 这是一个可以关闭的alert

Attribute

参数 关闭显示

Event

说明 类型 可选值 认值
事件名称 关闭时触发,是否显示false关闭时触发

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程之家。

相关文章

可以通过min-width属性来设置el-table-column的最小宽度。以...
yarn dev,当文件变动后,会自动重启。 yanr start不会自动重...
ref 用于创建一个对值的响应式引用。这个值可以是原始值(如...
通过修改 getWK005 函数来实现这一点。这里的 query 参数就是...
<el-form-item label="入库类型" ...
API 变动 样式类名变化: 一些组件的样式类名有所变动,可能需...
说明 回调参数