本文整理汇总了TypeScript中vuex-router-sync.sync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript sync函数的具体用法?TypeScript sync怎么用?TypeScript sync使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sync函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createApp
export function createApp() {
const router = createRouter()
const store = createStore()
sync(store, router)
const app = new Vue({
router,
store,
render: h => h(App)
})
return { app, router, store }
}
示例2: sync
export const createApp = (): IApp => {
sync(store, router);
HttpService.store = store;
const app: Vue = new Vue(
{
router,
store,
i18n,
render: (h) => h(App),
},
);
return { app, router, store, i18n };
};
示例3: createStore
const createApp = () => {
const store = createStore();
const router = createRouter();
sync(store, router);
const app = new Vue({
store,
router,
render: (h) =>
h(
'div',
{
attrs: {
id: 'app',
},
},
[h('blog')],
),
});
return {app, router, store};
};
示例4: Vue
Vue.use(VueDND);
Vue.use(VueCodemirror,{});
Vue.use(iView);
Vue.config.productionTip = false;
/* eslint-disable no-new */
const app = new Vue({
el: '#app',
router,
store,
components: { App },
template: '<App/>'
});
sync(store, router);
// progress&login
router.beforeEach((to, _from, next) => {
if (to.path === '/login') {
localStorage.removeItem('userInfo');
}
let userInfo = localStorage.getItem('userInfo');
if (false && !userInfo && to.path !== '/login') {
// next({ path: '/login' });
} else {
NProgress.start();
next();
}
});
router.afterEach(() => {
示例5: VueRouter
import App from './App';
Vue.use(VueRouter);
const router = new VueRouter();
const approuter = Vue.extend({});
router.map({
'/': {
component: App
}
});
sync(Store, router);
router.start(approuter, '#appContainer'); // must stay after map and syncing
/* eslint-disable no-console */
console.log(Store.state);
示例6: sync
import Vue from 'vue';
import axios from 'axios';
import VueAxios from 'vue-axios';
import { sync } from 'vuex-router-sync';
import store from './store';
import router from './router';
import app from './components/app.vue';
Vue.use(VueAxios, axios);
const unsync = sync(store, router);
const vm = new Vue({
components: {
app
},
el: '#app',
template: '<app />',
router,
store
});
示例7: vuexRouterSync
import './filters'
import './material'
import router from './router'
import store from './store'
// Styles
import './styles/main.scss'
// Scripts
// import 'expose-loader?$!expose-loader?jQuery!jquery'
// import "expose-loader?Tether!tether"
// import 'bootstrap'
// import 'expose-loader?mdc!../node_modules/material-components-web/dist/material-components-web.js'
vuexRouterSync(store, router)
Vue.use(VuePaginate)
Vue.use(Vuelidate)
Vue.use(Vue2Filters)
Vue.use(VueResource)
Vue.use(VueAsyncComputed)
new Vue({
...require('./views/main.vue'),
router,
store,
el: 'main',
})