前言
本文主要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
Attribute
说明 | 类型 | 可选值 | 默认值 |
---|---|---|---|
Event
说明 | 回调参数 |
---|---|