我有一个'native-script vue'应用程序,并且在第一页上,数据通过created()方法自动显示。
created() {
//shows data on screen
this.enableLocationServices();
alert('created');
},
一切都很好,但是由于我已经在项目中添加了vue路由器,所以我永远无法访问该“ created()”方法。
Vue路由器配置正确,因为我可以访问第二页,甚至更好,当我进入第二页并回到第一页时,将加载created()方法。 (我通过查看“创建的”警报知道了这一点)
这是我加载第一页的方式(我认为问题不在这里) HelloWorld是我的第一页,而City是第二页。
const router = new VueRouter({
pageRouting: true,
routes: [
{path: '/master', component: HelloWorld},
{path: '/city', component: City},
{path: '*', redirect: '/master'}
]
});
router.replace('/master');
new Vue({
router,
}).$start();
希望我清楚了myslef,在这里我的项目适合那些想要的人。 https://github.com/Thomas-Philippot/Application-meteo
谢谢你们!