vue中使用element ui,进入页面左下角强制弹窗

7 篇文章 0 订阅
5 篇文章 0 订阅

两种方法:

layout/index页面
一种是样式用ul,li,会自动落下

template(html)部分

<div class="floatclass">
      <ul
        class="box-card alarmRedBar"
        v-for="(item, index) in noticeList"
        :key="index"
      >
        <el-button
          type="text"
          class="textClose"
          @click="close(item)"
          icon="el-icon-circle-close"
        >
        </el-button>
        <li class="text item">信息名称: {{ item.message}}</li></li>
      </ul>
    </div>

第二种:循环触发for循环
template(html)部分:

<div class="floatclass">
      <el-card
        class="box-card"
        v-for="(item, index) in noticeList"
        :key="index"
      >
        <div class="text item">计划名称: {{ item.message}}</div>
      </el-card>
    </div>

methods方法代码:

 //关闭
 close(ite) {
      this.noticeList.some((item, i) => {
        if (item.planId == ite.planId) {
          this.noticeList.splice(i, 1);
          // 在数组的some方法中,如果return true,就会立即终止这个数组的后续循环,所以相比较foreach,如果想要终止循环,那么建议使用some
          return true;
        }
      });
    },
 getNoticeList() {
      getNoticeList().then((res) => {
        if (res.code == 200) {
          this.noticeList = res.rows;
          for (var i = 0; i < this.noticeList.length; i++) {
            this.open(i,this.noticeList[i]);
          }
        }
      });
    },
    open(i,noticeList) {
      const h = this.$createElement;
      this.$notify({
        title: "标题名称",
        message:noticeList.message,
        position:"bottom-left",
        offset:i * 80
      });
    },

css部分:

.floatclass {
  display: flex;
  -ms-flex-pack: center;
  flex-wrap: wrap;
  flex-direction: column;
  position: absolute;
  left: -200px;
  bottom: 5px;
}
.alarmRedBar {
  width: 200px;
  height: 88px;
  /* position: absolute;
  cursor: move;
  top: 89%;
  left: 1%; */
  z-index: 1001;
}
ul {
  /* margin: 0; */
  margin: 2px 2px;
  padding: 0;
}
.el-button--medium.is-round {
  padding: 3px 14px;
  font-size: 13px;
}
.el-button--medium {
  font-size: 13px;
}
ul li {
  list-style-type: none;
}
.textClose {
  float: right;
  margin-top: -11px;
  margin-right: 5px;
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Vue使用Element UI进行表单验证可以通过以下步骤来实现: 1. 首先,确保你的项目已经安装了Element UI组件库并正确引入。你可以使用npm或者yarn来安装Element UI,然后在你的Vue组件通过import语句引入所需的组件。 2. 在Vue组件,你可以使用Element UI提供的Form组件来创建表单,并使用Form Item组件来包含表单项。 3. 对于每个表单项,你可以使用Element UI提供的校验规则来定义验证规则。你可以通过设置prop属性来指定验证类型,比如required、email等,并通过设置rules属性来定义具体的验证规则。你还可以通过设置消息属性来定义验证失败时的提示信息。 4. 在表单提交时,你可以调用Element UI提供的validate方法来触发表单验证。如果验证通过,你可以继续处理表单数据;如果验证失败,你可以显示提示信息。 下面是一个示例代码,演示了如何在Vue使用Element UI进行表单验证: ```vue <template> <el-form ref="form" :model="formData" :rules="formRules" label-width="120px"> <el-form-item label="用户名" prop="username"> <el-input v-model="formData.username"></el-input> </el-form-item> <el-form-item label="密码" prop="password"> <el-input v-model="formData.password" type="password"></el-input> </el-form-item> <el-form-item> <el-button type="primary" @click="submitForm">提交</el-button> </el-form-item> </el-form> </template> <script> import { mapActions } from 'vuex'; export default { data() { return { formData: { username: '', password: '', }, formRules: { username: [ { required: true, message: '请输入用户名', trigger: 'blur' }, ], password: [ { required: true, message: '请输入密码', trigger: 'blur' }, ], }, }; }, methods: { ...mapActions(['login']), submitForm() { this.$refs.form.validate((valid) => { if (valid) { // 表单验证通过,继续处理提交逻辑 this.login(this.formData); // 调用Vuex action提交表单数据 } else { // 表单验证失败,显示提示信息 this.$message.error('表单验证失败,请检查输入'); } }); }, }, }; </script> ``` 在上述示例,我们使用Element UI的Form和FormItem组件来创建了一个包含用户名和密码输入框的表单。通过设置prop属性和rules属性,我们定义了用户名和密码的验证规则。在提交表单时,我们调用了validate方法来触发表单验证,并根据验证结果进行相应的处理。 希望以上信息对你有所帮助!<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [使用element-ui +Vue 解决 table 里包含表单验证的问题](https://download.csdn.net/download/weixin_38566180/12849766)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [解决vue+ element ui 表单验证有值但验证失败问题](https://download.csdn.net/download/weixin_38659159/12928895)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [系统基于springboot框架,使用Java+vue编写,为前后端分离的微服务项目](https://download.csdn.net/download/Abelon/88250447)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值