vue子组件的值改变后给出是否确认更改的提示,确认再改变输入框中的值

27 阅读2分钟

自学几个月前端,为什么感觉什么都没学到??


这种现象在很多的初学者和自学前端的同学中是比较的常见的。

因为自学走的弯路是比较的多的,会踩很多的坑,学习的过程中是比较的迷茫的。

最重要的是,在学习的过程中,不知道每个部分该学哪些知识点,学到什么程度才算好,学了能做什么。

很多自学的朋友往往都是自己去找资料学习的,资料上有的或许就学到了,资料上没有的或许就没有学到。

这就会给人一个错误的信息就是,我把资料上的学完了,估计也-就差不多的了。

但是真的是这样的吗?非也,因为很多人找的资料就是很基础的。学完了也就是掌握一点基础的东西。分享给你一份前端分析路线,你可以参考。

还有很多的同学在学习的过程中一味的追求学的速度,很快速的刷视频,写了后面忘了前面,最后什么都没有学到,什么都知道,但是什么都不懂,要具体说,也说不出个所以然。

所以学习编程一定要注重实践操作,练习敲代码的时间一定要多余看视频的时间。 开源分享:docs.qq.com/doc/DSmRnRG…

  • @tips 父级传递的错误信息 类型:字符 默认:'' 备注:有值就显示

  • @value 父级传递的默认值 类型:字符 默认:''

  • @disabled 父级传递的是否禁用 类型:布尔 默认:false

  • @isCheck 父级传递的是否必填 类型:布尔 默认:false

  • @isErr 父级传递的是显示爆红(错误提示) 类型:布尔 默认:false

  • */

export default {

name: "RelativePath",

props: {

getInputVal: {

type: Function,

default: function() {

return () => {};

}

},

title: {

type: String,

default: "模块名称"

},

tips: {

type: String,

default: ""

},

isCheck: {

type: Boolean,

default: false

},

isErr: {

type: Boolean,

default: false

},

value: {

type: [String, Number],

default: ""

},

disabled: {

type: Boolean,

default: false

},

popoverText: {

type: String,

default: ""

},

gitInputBlur: {

type: String,

default: ""

},

serviceVal: {

type: [String, Number],

default: ""

},

serviceSwitch: {

// 是否开启服务访问

type: Boolean,

default: false

},

serviceWarning: {

// 提示消息

type: String,

default: ""

},

modify: {

// 修改页面才弹确认框

type: Boolean,

default: false

}

},

watch: {

serviceSwitch: {

handler(val) {

this.needCheck = val;

},

deep: true

}

},

created() {

this.val = this.serviceVal;

this.needCheck = this.serviceSwitch;

},

data() {

return {

error: true, //验证是否通过 默认验证通过

reg: /(^ +| +$)/gi, //校验为空

val: this.value, //输入的数据

is_err: this.isErr,

needCheck: false,

oldInputVal: ""

};

},

methods: {

//获取焦点事件

inputFocus() {

this.is_err = false;

this.oldInputVal = this.val;

},

//失去焦点事件

inputBlur() {

let isCheck = this.isCheck;

let val = "";

if (this.val && typeof this.val == "string") {

val = this.val.replace(this.reg, "");

}

this.val = val;

if (isCheck) {

if (val == "") {

this.is_err = true;

}

} else {

this.is_err = false;

}

let reg = /^[0-9a-zA-Z-]{1,}$/;

if (!reg.test(this.val)) {

this.$message.error({

message: "服务名只支持字母数字中划线~",

duration: 3000

});

this.is_err = true;

} else {

if (this.needCheck && this.modify) {

this.confirm(confirm(`{this.serviceWarning}`, "提示", {

confirmButtonText: "确定",

cancelButtonText: "取消",

type: "warning"

})

.then(() => {

this.$message({

type: "success",

message: "修改成功!"

});

})

.catch(() => {

this.val = this.oldInputVal;

this.$message({

type: "info",

message: "已取消修改"

});

});

}

this.getInputVal(this.val);

}

}

}

};

.InputVal { .el-button--mini.is-circle { margin-left: 5px; padding: 0px; } .flag { padding-right: 5px; position: relative; top: 2px; color: red; } .msg { font-size: 12px; color: #ccc !important; } }

总结

技术学到手后,就要开始准备面试了,找工作的时候一定要好好准备简历,毕竟简历是找工作的敲门砖,还有就是要多做面试题,复习巩固。

开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】