问题描述
阅读这篇文章Manual routing on nativescript vue
main.js:
import Vue from 'nativescript-vue'
import routes from './router'
Vue.prototype.$router = routes
Vue.prototype.$goto = function(to,options) {
this.$navigateto(this.$routes[to],options)
}
new Vue({
render: h => h('frame',[h(routes['home'])])
}).$start()
routes.js:
import Home from "./views/Home";
import Page1 from "./views/Page1";
import Page2 from "./views/Page2";
const routes = {
home: Home,page1: Page1,page2: Page2
}
export default routes
Home.vue:
<template>
<Page class="page">
<ActionBar class="action-bar">
<Label class="action-bar-title" text="This is Home Component"></Label>
</ActionBar>
<StackLayout>
<Button text="Page 1" horizontalAlignment="center" @tap="$goto('page1')" />
</StackLayout>
</Page>
</template>
<script>
export default { }
</script>
此错误正在触发
System.err:“主”线程上发生未捕获的异常。 System.err: 调用 js 方法 onClick 失败 System.err: TypeError: 无法读取未定义的属性“page1”
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)