我的Vue之小功能统计
进行安装也可以使用的终端进行安装
npm install vue-router
npm install --save axios
npm install vuex --save
npm install --save-dev sass-loader
//sass-loader依赖于node-sass
npm install --save-dev node-sass
npm i element-ui -S
import Vue from 'vue'
import App from './App'
import router from './router'
import axios from 'axios'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import VueRouter from 'vue-router'
import Vuex from 'vuex'
Vue.use(ElementUI)
Vue.use(VueRouter)
Vue.use(Vuex)
new Vue({ 二.路由配置(index.js)
export default new Router({
routes: [ 的解决方法 export default new Router({
routes: [ }) 三.储存,传值 1.Cookie
//设置cookie
export function setCookie(key,value) {
var Days = 0.6;
var exdate = new Date(); //获取时间
exdate.setTime(exdate.getTime() + Days*24*60*60*1000); //保存的天数
//字符串拼接cookie
window.document.cookie = key + "=" + value + ";path=/;expires=" + exdate.toGMTString();
};
//读取cookie
export function getCookie(param) {
var c_param = '';
if (document.cookie.length > 0) {
var arr = document.cookie.split('; '); //这里显示的格式需要切割一下自己可输出看下
for (var i = 0; i < arr.length; i++) {
var arr2 = arr[i].split('='); //再次切割
//判断查找相对应的值
if (arr2[0] == param) {
c_param = arr2[1];
//保存到保存数据的地方
}
}
return c_param;
}
};
function padLeftZero (str) {
//cookie
import {setCookie,getCookie}from '../router/cookieUtil'
//储存用户信息
setCookie('sellerId',this.information.sellerId);
//取值用户信息
this.sellerId = getCookie("sellerId");
mounted () {
this.sellerId = getCookie("sellerId");
if (this.sellerId==undefined||this.sellerId=="") {
this.$router.push('/')
} else {
},methods: { ?2.Session Storage
sessionStorage.setItem('aaa',"111")
alert(sessionStorage.getItem('aaa'))
3.通过路由带参数进行传值 .$router.push({ path: '/B',query: { orderId: 123 } })
B获取 let aaa=.$route.query.orderId
四.发送验证码
export default {
data() {
return {
disabled:false,time:0,btntxt:"发送验证码",};
},methods: {
//发送手机验证码倒计时
timer() {
if (this.time > 0) {
this.time--;
this.btntxt=this.time+"s后重新获取";
setTimeout(this.timer,1000);
} else{
this.time=0;
this.btntxt="发送验证码";
this.disabled=false;
}
},}
}
五.div自适应屏幕宽高
export default {
六.实时显示当前时间
export default {
created() {
timeFormate(timeStamp) {
七.自定义滚动列表
.right-select{
width: 500px;
height: 105px;
overflow-y: scroll;
border: 1px solid #bbbbbb;
border-radius: 5px;
margin-left: 65px;
}
.right-select::-webkit-scrollbar {
width: 12px;
background-color: #fff;
}
.right-select::-webkit-scrollbar-thumb {
height: 26px;
background-color: #666;
border-radius: 50px;
}
? 八.判断数据列表序号
list: [{
name: '张一',id: '1241',source: '经销商',{
name: '张二',id: '1242',source: '业务员',{
name: '张三',id: '1243',source: '普通用户',{
name: '张四',id: '1244',source: '商城',}],
九.Form表单提交
export default {
data() {
return {
reportForm: {
name: '',sex:'',age: '',}
}
},methods: {
sub() {
let reportdata = this.reportForm;
console.log(reportdata)
}
}}
十.实现分页效果
序号
姓名
手机号
性别
用户等级
上级用户
创建日期
操作
{{ index+1>9?index+1:"0"+(index+1) }}
{{ item.name }}
{{ item.phone }}
{{ item.sex==1?"男":"女" }}
{{ item.user }}
{{ item.username }}
{{ item.date }}
<查看<修改<删除
<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;">
} 十一.悬浮改变图片和文字颜色
所有用户
export '../../images/alluser.png'
enter1: .img1 = require('../../images/alluser2.png'.img1 = require('../../images/alluser.png'
解决就好。 十二.单选按钮控制模块显示隐藏
v-model="radio" label无v-model="radio" 有
我出来了
export '0'
(.radio==="1".show=.show=
十三.搜索功能
搜索
{{ index+1>9?index+1:"0"+(index+1) }}
{{item.userID}}
{{item.agentnum}}
{{item.username}}
{{item.phone}}
{{ index+1>9?index+1:"0"+(index+1) }}
{{item.userID}}
{{item.agentnum}}
{{item.username}}
{{item.phone}}
十四.点击按钮复制文字
分享链接
{{address}}
复制链接
export 'https://www.baidu.com/'
= document.createElement('input''value', (document.execCommand('copy''copy'
十五.点击按钮下载图片
分享二维码
下载二维码
export "../../images/qrcode.png"
alink = document.createElement("a"= = "二维码";
.qrcodeshow=
十五.input框禁止输入负数和小数
= RegExp("^[1-9][0-9]*$"(!.$message.warning("请输入正整数!"..num = '1'
还在持续更新中~,觉得有帮助的麻烦关注一下,谢谢! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |