我正在使用ionic3进行app的开发,我遇到了一个问题,我在ts页面注入了一个服务,服务代码如下:import { Injectable } from '@angular/core';
@Injectable()
export class FakerdataService {
constructor () {
}
button = [
{name: '拜访客户',title: 'contacts',num: 'Page1Page'},
{name: '考勤登记',title: 'book',num: 'Page2Page'},
{name: '拜访路线',title: 'subway',num: 'Page2Page'},
{name: '订单管理',title: 'reorder',num: 'Page1Page'}
]
button2 = [
{name: '拜访客户',title: 'contacts',num: 'Page1Page'},
{name: '考勤登记',title: 'book',num: 'Page2Page'}
]
}
然后我现在本页面做了一个for循环语句想动态的加载页面,代码如下: openPage(page) {
for(let n=0;n<this.buttons.length;n++){
console.log(n)
// console.log(this.buttons[n].num)
this.nav.setRoot(this.buttons[n].num)
}
}
可是在浏览器调试的时候,点击前俩个操作是正常的,再进行操作的时候,就变成了最后一个值,我查了一些资料也没有解决,想大神们帮我看一看,提前感谢!!
你这this.buttons是? 没有定义吧