1 line
38 KiB
JavaScript
1 line
38 KiB
JavaScript
|
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?module.exports=factory():"function"==typeof define&&define.amd?define(factory):global.VueRouter=factory()}(this,function(){"use strict";function assert(condition,message){if(!condition)throw new Error("[vue-router] "+message)}function warn(condition,message){condition||"undefined"!=typeof console&&console.warn("[vue-router] "+message)}function isError(err){return Object.prototype.toString.call(err).indexOf("Error")>-1}var View={name:"router-view",functional:!0,props:{name:{type:String,default:"default"}},render:function(_,ref){var props=ref.props,children=ref.children,parent=ref.parent,data=ref.data;data.routerView=!0;for(var h=parent.$createElement,name=props.name,route=parent.$route,cache=parent._routerViewCache||(parent._routerViewCache={}),depth=0,inactive=!1;parent&&parent._routerRoot!==parent;)parent.$vnode&&parent.$vnode.data.routerView&&depth++,parent._inactive&&(inactive=!0),parent=parent.$parent;if(data.routerViewDepth=depth,inactive)return h(cache[name],data,children);var matched=route.matched[depth];if(!matched)return cache[name]=null,h();var component=cache[name]=matched.components[name];data.registerRouteInstance=function(vm,val){var current=matched.instances[name];(val&¤t!==vm||!val&¤t===vm)&&(matched.instances[name]=val)},(data.hook||(data.hook={})).prepatch=function(_,vnode){matched.instances[name]=vnode.componentInstance};var propsToPass=data.props=function(route,config){switch(typeof config){case"undefined":return;case"object":return config;case"function":return config(route);case"boolean":return config?route.params:void 0;default:warn(!1,'props in "'+route.path+'" is a '+typeof config+", expecting an object, function or boolean.")}}(route,matched.props&&matched.props[name]);if(propsToPass){propsToPass=data.props=function(to,from){for(var key in from)to[key]=from[key];return to}({},propsToPass);var attrs=data.attrs=data.attrs||{};for(var key in propsToPass)component.props&&key in component.props||(attrs[key]=propsToPass[key],delete propsToPass[key])}return h(component,data,children)}};var encodeReserveRE=/[!'()*]/g,encodeReserveReplacer=function(c){return"%"+c.charCodeAt(0).toString(16)},commaRE=/%2C/g,encode=function(str){return encodeURIComponent(str).replace(encodeReserveRE,encodeReserveReplacer).replace(commaRE,",")},decode=decodeURIComponent;function parseQuery(query){var res={};return(query=query.trim().replace(/^(\?|#|&)/,""))?(query.split("&").forEach(function(param){var parts=param.replace(/\+/g," ").split("="),key=decode(parts.shift()),val=parts.length>0?decode(parts.join("=")):null;void 0===res[key]?res[key]=val:Array.isArray(res[key])?res[key].push(val):res[key]=[res[key],val]}),res):res}function stringifyQuery(obj){var res=obj?Object.keys(obj).map(function(key){var val=obj[key];if(void 0===val)return"";if(null===val)return encode(key);if(Array.isArray(val)){var result=[];return val.forEach(function(val2){void 0!==val2&&(null===val2?result.push(encode(key)):result.push(encode(key)+"="+encode(val2)))}),result.join("&")}return encode(key)+"="+encode(val)}).filter(function(x){return x.length>0}).join("&"):null;return res?"?"+res:""}var trailingSlashRE=/\/?$/;function createRoute(record,location,redirectedFrom,router){var stringifyQuery$$1=router&&router.options.stringifyQuery,query=location.query||{};try{query=clone(query)}catch(e){}var route={name:location.name||record&&record.name,meta:record&&record.meta||{},path:location.path||"/",hash:location.hash||"",query:query,params:location.params||{},fullPath:getFullPath(location,stringifyQuery$$1),matched:record?function(record){var res=[];for(;record;)res.unshift(record),record=record.parent;return res}(record):[]};return redirectedFrom&&(route.redirectedFrom=getFullPath(redirectedFrom,stringifyQuery$$1)),Object.freeze(route)}function clone(value){if(Array.isArray(value))return value.map(clone);if(value&&"object"==typeof value){var res={};for(var key in value)res[key]=clone(value[key]);return res}return value}var START=createRoute(null,{path:"/"});function
|