荣兄面试精华
作者:互联网
荣兄面试精华
// An highlighted block
var foo = 'bar';
<template>
<div class="rotate_contanier">
<div>
<label>份数</label>
<input type="text" v-model="fenshu" />
</div>
<div>
<label>描述</label>
<textarea v-model="miaoshu"></textarea>
</div>
<div>
<label>天数</label>
<input type="text" v-model="tianshu" />
</div>
<button @click="save">保存</button>
</div>
</template>
<script>
export default {
data () {
return {
fenshu: '',
miaoshu: '',
tianshu: ''
}
},
methods: {
save () {
const reg = /^\d+$|^\d+[.]?\d+$/
this.miaoshu = this.miaoshu.replace(/bug|bad/g, '**')
if (this.fenshu.length === 0) {
alert('份数为必填!')
} else if (this.fenshu.length < 10 || this.fenshu.length > 20) {
alert('份数不能小于10或者大于20!')
} else if (this.miaoshu.length === 0) {
alert('描述为必填!')
} else if (!reg.test(this.tianshu)) {
alert('只能输入数字!')
} else {
alert('保存成功!')
}
}
}
}
</script>
<style>
</style>
标签:miaoshu,份数,else,fenshu,alert,面试,length,精华,荣兄 来源: https://blog.csdn.net/Methodss/article/details/114659769