[improvement] Cell: functional (#2729)

This commit is contained in:
neverland
2019-02-13 15:37:11 +08:00
committed by GitHub
parent a08666947f
commit 4aad9add9c
19 changed files with 162 additions and 129 deletions
-22
View File
@@ -1,22 +0,0 @@
/**
* Common Cell Props
*/
export default {
props: {
icon: String,
center: Boolean,
isLink: Boolean,
required: Boolean,
titleClass: String,
valueClass: String,
labelClass: String,
title: [String, Number],
value: [String, Number],
label: [String, Number],
border: {
type: Boolean,
default: true
}
}
};
-22
View File
@@ -1,22 +0,0 @@
/**
* add Vue-Router support
*/
export default {
props: {
url: String,
replace: Boolean,
to: [String, Object]
},
methods: {
routerLink() {
const { to, url, $router, replace } = this;
if (to && $router) {
$router[replace ? 'replace' : 'push'](to);
} else if (url) {
replace ? location.replace(url) : location.href = url;
}
}
}
};
+31
View File
@@ -0,0 +1,31 @@
/**
* add Vue-Router support
*/
import { RenderContext } from 'vue';
import VueRouter, { RawLocation } from 'vue-router/types';
export type RouteConfig = {
url?: string;
to?: RawLocation;
replace?: boolean;
};
export function route(router: VueRouter, config: RouteConfig) {
const { to, url, replace } = config;
if (to && router) {
router[replace ? 'replace' : 'push'](to);
} else if (url) {
replace ? location.replace(url) : (location.href = url);
}
}
export function functionalRoute(context: RenderContext) {
route(context.parent && context.parent.$router, context.props);
}
export const routeProps = {
url: String,
replace: Boolean,
to: [String, Object]
};