Vue-获取解析地址栏的参数包括中文参数
2023-09-11 14:18:36 时间
getQueryString (name) { var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)') var r = window.location.search.substr(1).match(reg) if (r != null) { return unescape(r[2]) } return null }, getRequest (key) { // 获取参数 var url = window.location.search // 正则筛选地址栏 var reg = new RegExp('(^|&)' + key + '=([^&]*)(&|$)') // 匹配目标参数 var result = url.substr(1).match(reg) // 返回参数值 return result ? decodeURIComponent(result[2]) : null },
第一个不能解析中文
第二个能
保存到本地
localStorage.setItem('user_id', this.getQueryString('user_id'))
localStorage.setItem('roleid', this.getQueryString('roleid'))
localStorage.setItem('department_id', this.getQueryString('department_id'))
this.type = this.getQueryString('type')
this.username = this.getRequest('username')
this.password = this.getRequest('password')
相关文章
- Vue_(Router路由)-vue-router路由的基本用法
- Vue -> 解决 vue-ueditor-wrap 不能显示的问题
- VUE - 取消默认事件
- Vue.js3: 页面打开前实现图片全部预加载(vue@3.2.33)
- vue.js开发SPA常见问题及解决方法
- [Vue @Component] Control Template Contents with Vue's Render Function
- [Vue @Component] Simplify Vue Components with vue-class-component
- vue.js3: 用crypto-js做sha加密(vue@3.2.37 / crypto-js@4.1.1)
- vue 的 render 函数的用法:new Vue({ render: h => h(App), }).$mount(‘#app‘)
- uni-app与Vue的区别
- vue 日期时间过滤器
- vue实现点击关注之后及时更新列表
- 前端MVC Vue2学习总结(二)——Vue的实例、生命周期与Vue脚手架(vue-cli)
- vue中assets和static的区别
- Vue中vue-i18n结合vant-ui实现国际化
- Vue、Vuejs从入门到精通 | vue-router详解
- 196:vue+openlayers 滑动某feature高亮,修改此feature的样式
- 071:vue+openlayers轨迹路线动画(示例代码)
- Vue(五)计算属性、过滤器、axios、vue 生命周期
- vue-tour快速入门:VUE项目中如何使用vue-tour新手引导指引插件?怎样使用?包含具体实例
- Error: Cannot find module ‘../../xxx.vue‘
- Vue: vue-router路由
- Vue:第一个vue-cli项目
- vue.js
- vue路由传递参数的几种方式详解