vue-js

1、设置当前页面color

在mounted 里面写:

document.querySelector('body').setAttribute('style', 'background-color:#fff')

2、链接跳转及传参、接收参数

方法一:

this.$router.push({
                    path: '/group/groupDetail',
                    query: {
                        item_id: item.item_id,
                        
                    }
                });
this.$route.query.item_id;

 方法二:

在style.js文件中先定义这个方法

//获取连接参数
    GetQueryString(name) {
        return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ""])[1].replace(/\+/g, '%20')) || null
    },

使用: 例如连接后面参数为 test_id

GetQueryString("test_id");

3、获取网页上的连接

window.location.href

4、如果页面没有上一层路由,直接返回首页

if (window.history.length <= 1) {
                    this.$router.push({path:'/home'})
                    return false
                } else {
                    this.$router.go(-1)
                }

5、解析动态json数据

取出key和value的值。再封装到一个数组里面。 

let userData = res.data.data;
let userArray=[];
for (let [key, value] of Object.entries(userData)) {
  userArray.push({"时间":key,"人数":value});
  console.log(userArray)
}

只取key值:

for (let key of Object.keys(obj)) {
  
}

只取value值:

for (let value of Object.values(obj)) {
  
}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值