vue 自定义公共方法
1. 创建自定义 utils.js文件

一个获取url参数的方法
function getUrlKey(name) {
return (
decodeURIComponent(
(new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(
location.href
) || [, ''])[1].replace(/\+/g, '%20')
) || null
);
}
export default {
getUrlKey,
};2. 注册全局方法

//公共js方法
import utils from './utils' Vue.prototype.$utils = utils
3. 调用此方法
this.$utils.getUrlKey('id')