如何解决为什么我无法读取 nativescript 上的路由属性?
阅读这篇文章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 举报,一经查实,本站将立刻删除。