返回

element-ui那些坑,害我踩碎了新买的鞋

前端

一、Message组件

1. Message组件的duration属性

Message组件的duration属性用于设置提示消息的显示时间,默认值为3秒。如果我们想要延长提示消息的显示时间,可以将duration属性的值设置为一个更大的值,例如5秒或10秒。

this.$message({
  message: '提示消息',
  duration: 5000
});

2. Message组件的showClose属性

Message组件的showClose属性用于控制是否显示关闭按钮。默认情况下,showClose属性的值为true,即显示关闭按钮。如果我们想要隐藏关闭按钮,可以将showClose属性的值设置为false

this.$message({
  message: '提示消息',
  showClose: false
});

3. Message组件的type属性

Message组件的type属性用于设置提示消息的类型。Message组件支持四种类型的提示消息:successwarninginfoerror。默认情况下,type属性的值为info

this.$message({
  message: '提示消息',
  type: 'success'
});

二、Notification组件

1. Notification组件的duration属性

Notification组件的duration属性用于设置提示消息的显示时间,默认值为4.5秒。如果我们想要延长提示消息的显示时间,可以将duration属性的值设置为一个更大的值,例如5秒或10秒。

this.$notify({
  message: '提示消息',
  duration: 5000
});

2. Notification组件的showClose属性

Notification组件的showClose属性用于控制是否显示关闭按钮。默认情况下,showClose属性的值为true,即显示关闭按钮。如果我们想要隐藏关闭按钮,可以将showClose属性的值设置为false

this.$notify({
  message: '提示消息',
  showClose: false
});

3. Notification组件的type属性

Notification组件的type属性用于设置提示消息的类型。Notification组件支持四种类型的提示消息:successwarninginfoerror。默认情况下,type属性的值为info

this.$notify({
  message: '提示消息',
  type: 'success'
});

三、MessageBox组件

1. MessageBox组件的title属性

MessageBox组件的title属性用于设置提示框的标题。如果我们想要设置提示框的标题,可以将title属性的值设置为一个字符串。

this.$msgbox({
  title: '提示框标题',
  message: '提示消息'
});

2. MessageBox组件的message属性

MessageBox组件的message属性用于设置提示框的内容。如果我们想要设置提示框的内容,可以将message属性的值设置为一个字符串。

this.$msgbox({
  title: '提示框标题',
  message: '提示消息'
});

3. MessageBox组件的type属性

MessageBox组件的type属性用于设置提示框的类型。MessageBox组件支持四种类型的提示框:alertconfirmpromptwarning。默认情况下,type属性的值为alert

this.$msgbox({
  title: '提示框标题',
  message: '提示消息',
  type: 'confirm'
});

结语

以上就是我在使用element-ui时踩过的坑。希望这些经验能够帮助大家避免同样的问题,在使用element-ui的过程中更加得心应手。