摘要:功能,所以我在这里进行一个汇总,后面会持续添加至这篇博客,希望当你遇到这个功能时,我的博客能够对你有帮助,(上一篇博客说要在收假后写一篇博客做一个年终总结,想了半天不知道写什么,文笔不好,就算了,不写了,今天是情人节,祝没有脱单的程序员赶快脱单,脱单了的永不脱发,脱发了的就当我没说......)
图片如下:可使用进行安装也可以使用的终端进行安装
new Vue({
el: '#app',router,components: { App },template: '
二.路由配置(index.js)
图片如下(进行路由跳转)
routes: [
{
path: '/',name: 'Login',component: Login,},{
path: '/Forget',name: 'Forget',component: Forget,{
path: '/',component: Home,name: '用户管理',children: [
{ path: '/User',component: User,name: '用户'},{ path: '/SeeEdit',component: SeeEdit,name: '用户详情'},{ path: '/Modify',component: Modify,name: '修改用户资料'},{ path: '/changepsw',component: changepsw,name: '修改密码'},]
},......
],})
页面的解决方法
routes: [
......
],scrollBehavior (to,from,savedPosition) {
// console.log(to) // to:要进入的目标路由对象,到哪里去
// console.log(from) // from:离开的路由对象,哪里来
// console.log(savedPosition) // savePosition:会记录滚动条的坐标
if(savedPosition) {
return savedPosition;
}else{
return {x:0,y:0}
}
}
})
三.储存,传值
1.Cookie
文件
function padLeftZero (str) {
return ('00' + str).substr(str.length);
};
登录界面login.vue引用这个js
退出登录
}
},methods: {
//退出
Signout(){
setCookie("sellerId","",-1);
this.$router.push('/')
},}
2.Session Storage
页面缓存aaa的值
页面去获取到值
3.通过路由带参数进行传值
B获取
四.发送验证码
图片如下
五.div自适应屏幕宽高
后台管理系统那种格式,有顶部导航栏和左侧导航栏,而切换的那一块盒子怎么能自适应屏幕的宽高减去顶部和左侧固定的宽高呢?
HTML代码:
代码:
data() {
return<span> {
myWidth: (window.innerWidth - 240) + 'px'<span>,myHeight: (window.innerHeight - 100) + 'px'<span>,}</span></span></span></span></pre>
六.实时显示当前时间
图片如下(想后台系统一般都会添加一个当前时间,方便用户了解或记录时间)
HTML代码
代码
data() {
return<span> {
nowTime:""<span>,nowWeek:""<span>,// 创建完成时
created() {
this.nowTimes();
},methods: {
//当前时间
timeFormate(timeStamp) {
let year = new Date(timeStamp).getFullYear();
let month =new Date(timeStamp).getMonth() + 1 < 10? "0" + (new Date(timeStamp).getMonth() + 1): new Date(timeStamp).getMonth() + 1;
let date =new Date(timeStamp).getDate() < 10? "0" + new Date(timeStamp).getDate(): new Date(timeStamp).getDate();
var week = timeStamp ? new Date(timeStamp) : new Date();
if(week.getDay() == 1){
this.nowWeek="周一"
} else if(week.getDay() == 2){
this.nowWeek="周二"
} else if(week.getDay() == 3){
this.nowWeek="周三"
} else if(week.getDay() == 4){
this.nowWeek="周四"
} else if(week.getDay() == 5){
this.nowWeek="周五"
} else if(week.getDay() == 6){
this.nowWeek="周六"
} else {
this.nowWeek="周日"
}
let hh =new Date(timeStamp).getHours() < 10? "0" + new Date(timeStamp).getHours(): new Date(timeStamp).getHours();
let mm =new Date(timeStamp).getMinutes() < 10? "0" + new Date(timeStamp).getMinutes(): new Date(timeStamp).getMinutes();
this.nowTime = year + "/" + month + "/" + date +" "+ this.nowWeek +" "+ hh +":"+ mm ;
// console.log(this.nowTime)
clearInterval(this.Times);
},// 定时器函数
nowTimes(){
this.timeFormate(new Date());
this.Times=setInterval(this.nowTimes,1000);
},}
页面一直崩溃,后来打印才发现是忘记清除定时器了,
七.自定义滚动列表
图片如下
HTML代码
代码
.right-select::-moz-scrollbar {
width: 12px;
background-color: #fff;
}
.right-select::-moz-scrollbar-thumb {
height: 26px;
background-color: #666;
border-radius: 50px;
}</pre>
自定义滚动条时,请记住要定义盒子的高度,不然滚动条会显示不出来
八.判断数据列表序号
图片如下
-
9?index+1:"0"+(index+1) }}
代码
九.Form表单提交
HTML代码
代码
效果图如下
HTML代码:
<span style="color: #0000ff;"><</span><span style="color: #800000;">div </span><span style="color: #ff0000;">class</span><span style="color: #0000ff;">="page"</span><span style="color: #0000ff;">></span>
<span style="color: #0000ff;"><</span><span style="color: #800000;">el-pagination
</span><span style="color: #ff0000;">@size-change</span><span style="color: #0000ff;">="handleSizeChange"</span><span style="color: #ff0000;">
@current-change</span><span style="color: #0000ff;">="handleCurrentChange"</span><span style="color: #ff0000;">
:current-page</span><span style="color: #0000ff;">="currentPage"</span><span style="color: #ff0000;">
:page-sizes</span><span style="color: #0000ff;">="[5,10,20,40]"</span><span style="color: #ff0000;">
:page-size</span><span style="color: #0000ff;">="pagesize"</span><span style="color: #ff0000;">
layout</span><span style="color: #0000ff;">="total,sizes,prev,pager,next,jumper"</span><span style="color: #ff0000;">
:total</span><span style="color: #0000ff;">="tableData.length"</span><span style="color: #0000ff;">></span>
<span style="color: #0000ff;"></</span><span style="color: #800000;">el-pagination</span><span style="color: #0000ff;">></span>
<span style="color: #0000ff;"></</span><span style="color: #800000;">div</span><span style="color: #0000ff;">></span>
<span style="color: #0000ff;"></
<span style="color: #800000;">template<span style="color: #0000ff;">>代码:
代码:
margin-bottom</span>:<span style="color: #0000ff;"> 30px</span>;<span style="color: #ff0000;">
float</span>:<span style="color: #0000ff;"> right</span>;<span style="color: #ff0000;">
font-size</span>:<span style="color: #0000ff;"> 20px</span>;<span style="color: #ff0000;">
color</span>:<span style="color: #0000ff;"> #333333</span>;<span style="color: #ff0000;">
margin-right</span>:<span style="color: #0000ff;"> 55px</span>;<span style="color: #ff0000;">
font-weight</span>:<span style="color: #0000ff;"> normal</span>;<span style="color: #ff0000;">
.el-select .el-input{
width</span>:<span style="color: #0000ff;"> 126px</span>;<span style="color: #ff0000;">
height</span>:<span style="color: #0000ff;"> 36px</span>;
}<span style="color: #800000;">
.el-select .el-input .el-input__inner</span>{<span style="color: #ff0000;">
height</span>:<span style="color: #0000ff;"> 100%</span>;<span style="color: #ff0000;">
font-size</span>:<span style="color: #0000ff;"> 20px</span>;<span style="color: #ff0000;">
color</span>:<span style="color: #0000ff;"> #333333</span>;
}<span style="color: #800000;">
.el-pagination__editor.el-input .el-input__inner</span>{<span style="color: #ff0000;">
height</span>:<span style="color: #0000ff;"> 36px</span>;
}<span style="color: #800000;">
.btn-prev,.btn-next</span>{<span style="color: #ff0000;">
height</span>:<span style="color: #0000ff;"> 36px</span>;
}<span style="color: #800000;">
.btn-prev</span>{<span style="color: #ff0000;">
border-radius</span>:<span style="color: #0000ff;"> 5px 0 0 5px</span>;
}<span style="color: #800000;">
.btn-next</span>{<span style="color: #ff0000;">
border-radius</span>:<span style="color: #0000ff;"> 0 5px 5px 0</span>;
}<span style="color: #800000;">
.el-pager li</span>{<span style="color: #ff0000;">
line-height</span>:<span style="color: #0000ff;"> 36px</span>;<span style="color: #ff0000;">
height</span>:<span style="color: #0000ff;"> 36px</span>;<span style="color: #ff0000;">
font-size</span>:<span style="color: #0000ff;"> 20px</span>;
}<span style="color: #800000;">
.el-pagination__total</span>{<span style="color: #ff0000;">
color</span>:<span style="color: #0000ff;"> #333333</span>;
}<span style="color: #800000;">
button,span:not([class*=suffix])</span>{<span style="color: #ff0000;">
height</span>:<span style="color: #0000ff;"> 36px</span>;<span style="color: #ff0000;">
line-height</span>:<span style="color: #0000ff;"> 36px</span>;<span style="color: #ff0000;">
font-size</span>:<span style="color: #0000ff;"> 20px</span>;<span style="color: #ff0000;">
color</span>:<span style="color: #0000ff;"> #333333</span>;
}<span style="color: #800000;">
.el-pagination__editor.el-input</span>{<span style="color: #ff0000;">
font-size</span>:<span style="color: #0000ff;"> 20px</span>;
}<span style="color: #800000;">
}
图片事例如下:
HTML代码:
代码:
文字样式改变的话,直接用css的解决就好。
十二.单选按钮控制模块显示隐藏
搜索
HTML代码:
代码:
搜索
HTML代码:
代码:
十四.点击按钮复制文字
HTML代码:
代码:
十五.点击按钮下载图片
HTML代码:
代码:
十五.input框禁止输入负数和小数
HTML代码:
代码:
还在持续更新中~,觉得有帮助的麻烦关注一下,谢谢!
原文链接:https://www.f2er.com/vue/74419.html