2
我已經在我的應用程序以下航線VueJs:如何訪問常用的JavaScript模塊的電流路徑元字段 -
const router = new Router({
mode: 'history',
scrollBehavior:() => ({ y: 0 }),
routes: [
{ path: '/', component: HomePage, meta: { pageType: 'home'} },
],
});
,並有共同的JS模塊:
const trackEvent = {
getFields:() => {
//here need to access meta fields(pageType) of current route. how is it possible ?
}
}
export default trackEvent;
我想訪問元領域在共同的模塊。這怎麼可能 ?
我有一些用例,我直接需要在JS模塊中訪問元字段而不從元件傳遞元字段。 –
好的,在這種情況下,您需要導入'router'對象。看我的編輯。 – thanksd