routeTo.js 319 字节
Newer Older
1 2 3 4 5 6 7 8
import {router} from 'san-router';

export function routeTo(url, params = {}) {
    let paramsArr = Object.keys(params).map(key => `${key}=${params[key]}`);
    let urlParams = (url.indexOf('?') > -1 ? '&' : '?') + paramsArr.join('&');

    router.locator.redirect(urlParams.length > 1 ? `${url}${urlParams}` : url);
}