需求

一个错误提示框,后台需要有换行,默认没有换行,做一个支持换行的全局错误提示函数。

注意

代码只展示原理,直接不能使用,里面有getAc,有需要参考 https://www.cnblogs.com/pengchenggang/p/17037428.html

预览

modalError代码

<template>
<div>
<Modal v-model="confirmZenVmodel"
:mask-closable="false"
width="700px"
footer-hide
:closable="false">
<div style="padding: 10px 40px 10px 20px;">
<Row>
<Col span="2"><i class="ivu-icon ivu-icon-ios-close-circle"
style="color: #ed4014; font-size:28px; float: right; margin-right: 10px;"></i></Col>
<Col span="22">
<div style="font-size: 18px; font-weight: bold; margin-top: 2px; margin-bottom: 10px;">错误信息</div>
<div v-html="text" style="min-height: 70px; max-height: 380px; overflow: auto; font-size: 12px;"></div>
</Col>
</Row>
<div>
<Button type="primary"
style="float: right; margin-top: 10px;"
@click="okBtnHandle">确定</Button>
</div>
<div style="clear: both;"></div>
</div>
</Modal>
</div>
</template> <script>
export default {
name: 'ConfirmZen',
data () {
return {
text: 'defaultText',
confirmZenVmodel: false,
baseOption: {
text: 'defaultText',
}
}
},
methods: {
cancelBtnHandle () {
this.cancelBtnHandleInner()
},
cancelBtnHandleInner (ctx, next) {
this.confirmZenVmodel = false
},
okBtnHandle () {
this.okBtnHandleInner()
},
okBtnHandleInner (ctx, next) {
this.confirmZenVmodel = false
},
open (option) {
const opt = { ...this.baseOption, ...option }
console.info('ConfirmZen open methods', opt)
if (option.cancelBtnHandle) {
this.cancelBtnHandle = () => {
this.$getAc()
.use(option.cancelBtnHandle)
.use(this.cancelBtnHandleInner)
.run()
}
} if (option.okBtnHandle) {
this.okBtnHandle = () => {
this.$getAc()
.use(option.okBtnHandle)
.use(this.okBtnHandleInner)
.run()
}
} this.text = opt.text
this.confirmZenVmodel = true
}
}
}
</script> <style scoped>
</style>

App.vue 绑定

<template>
<div id="app">
<router-view />
<modalError ref="modalErrorRef"></modalError>
</div>
</template>
<script>
import modalError from '@/components/modalError/modalError.vue'
import Vue from 'vue'
export default {
name: 'App',
components: {
modalError,
},
mounted () {
Vue.prototype.$modalError = this.$refs.modalErrorRef
},
</script>

代码使用

if (res.status === 43) {
this.$modalError.open({
text: JSON.parse(res.msg).join('<br><br>')
})
}

modalError.vue 错误提示框 vue2 iview的更多相关文章

  1. vue错误提示 Cannot read property 'beforeRouteEnter' of undefined,刷新后跳到首页

    vue错误提示 Cannot read property 'beforeRouteEnter' of undefined,刷新后跳到首页 因为vue-router版本太高了,我vue用的是2.3.4, ...

  2. vue 自定义 提示框(Toast)组件

    1.自定义 提示框 组件 src / components / Toast / index.js /** * 自定义 提示框( Toast )组件 */ var Toast = {}; var sho ...

  3. PLSQL登录失败出现空白错误提示框的问题

    安装win7后其他软件运行正常,可是数据库用cmd plsplus和plsql软件都连不上,plsql报一个空白提示框 重装n遍oracle客户端,都不行. 最后发现解决方式很简单,在plsql的图标 ...

  4. ValidationSummary控件不弹出错误提示框

    采用VS2013 编写的前台,运用ValidationSummary控件时,不出现错误弹窗,网上找到了解决方法 发现是ASP.NET 4.5对验证控件的影响(兼容性),使用ASP.NET 4.5的解决 ...

  5. 安装软件(名称不记得了)后,系统开机提示 visual studio just-in-time debugger窗口(WINDOWS错误提示框)

    出现这种情况,往往是因为原先安装有VS,后来因某些原因(比如:卸载)导致VS无法使用!!当系统中的有些软件出现错误时,会自动调用vs进行调试,但因为VS无法使用,就出现了visual studio j ...

  6. Process启动.exe,当.exe内部抛出异常时,总会弹出一个错误提示框,阻止Process进入结束

    public class TaskProcess { [DllImport("kernel32.dll", SetLastError = true)] public static ...

  7. webstorm去掉vue错误提示

  8. WPF 设置WebBrowser控件不弹脚本错误提示框

    using System.Reflection; using System.Windows; using System.Windows.Controls; using System.Windows.N ...

  9. Jquery 错误提示插件

    这是一个简单的输入框错误提示插件,可拓展! .jq-error{ font-size:12px; min-width:150px; width:auto; max-width:350px; line- ...

  10. Java的awt包的使用实例和Java的一些提示框

    一.awt的一些组件 Label l1=new Label("姓名:"); //标签 Label l2=new Label("密码:"); TextField ...

随机推荐

  1. MySQL【一】基本使用----超详细教学

    相关文章: win10下MySQL安装教程(MySql-8.0.26超级详细)_丨汀.的博客-CSDN博客 1.RDBMS(Relational Databases Management System ...

  2. Python 原生Socket实现端口扫描

    端口扫描,就是逐个对一段端口或指定的端口进行扫描.通过扫描结果可以知道一台计算机上都提供了哪些服务,Python中使用Socket即可实现对特定端口的探测,以及对C段的扫描. 扫描目标主机Banner ...

  3. 营销(marketing)、推广(Promotion)和 运营(Operation)的概念分别是什么?

    首先要明确的原则: 1.你得承认"讨论任何事情之前不弄清楚概念定义就是耍流氓" 2.你得承认"由于每个人的经验学识和理解力的不同,我们常对概念定义产生分歧" 3 ...

  4. HBase-宽表和高表的对比

    一.宽表和高表定义 HBase 中的表可以设计为高表(tall-narrow table) 和 宽表(flat-wide table): (1) 宽表是指很多列较少行,即列多行少的表,一行中的数据量较 ...

  5. 剑指Offer07 重建二叉树

    剑指 Offer 07. 重建二叉树 前置概念: 前序:访问根节点,先序遍历左子树,先序遍历右子树: 中序:中序遍历左子树,访问根节点,中序遍历右子树: 后序:后序遍历左子树,后序遍历右子树,访问根节 ...

  6. CF1851

    A 氵 B 把奇数和偶数拿出来分别排序,然后按下标归并,看看得出的结果是不是排好序的. C 如果头尾同色,就找有没有 \(k\) 个位置和头尾同色: 否则从头找 \(k\) 个和头同色的,然后再在这之 ...

  7. Python Split 函数用法

    一.split函数简介Python中split()函数,具体作用如下: 拆分字符串.通过指定分隔符对字符串进行切片,并返回分割后的字符串列表(list):二.语法split() 方法语法: str.s ...

  8. npm无法安装node-sass 的问题

    安装 node-sass 的问题呈现:4.9.0版本无法下载 Downloading binary from https://github.com/sass/node-sass/releases/do ...

  9. AIR32F103(十二) 搭载 AIR32F103CBT6 的Bluepill核心板

    目录 AIR32F103(一) 合宙AIR32F103CBT6开发板上手报告 AIR32F103(二) Linux环境和LibOpenCM3项目模板 AIR32F103(三) Linux环境基于标准外 ...

  10. 李宏毅2022机器学习HW3 Image Classification

    Homework3 数据集下载 在本地环境下进行实验总是令人安心,但是又苦于网上找不到数据集,虽然kaggle上有数据集但是下载存在问题 于是有了一个天才的想法,间接从kaggle上下载(利用outp ...