用nowa创建的dingtalk项目,路由应该怎么写?
用nowa创建的dingtalk项目,路由应该怎么写?
PageHome.jsx
require('./PageHome.less');
import logic from './PageLogic';
import { Control, Route } from 'react-keeper';
import { Component, LogicRender } from 'refast';
import TabBar, { activeTabbar } from 'components/card-tabbar';
import { NavBar } from 'antd-mobile';
class Home extends Component {
constructor(props) { super(props, logic);
this.handleChange = this.handleChange.bind(this);
}
handleChange(key){
this.dispatch('setTabbarIndex',key);
Control.go(this.state.menu[key].path, ); // keeper的跳转
alert(this.props.children);
}
render() {
const { state: { menu, tabbarIndex, badge, }, } = this;
const activeIndex=activeTabbar( menu );
if (tabbarIndex != activeIndex ){ // 对比url索引和当前选中的值,如不对应则纠正.
this.dispatch('setTabbarIndex',activeIndex);
}
return (
<div className="home">
<NavBar
iconName=""
mode="light">
菜单
</NavBar>
{/*中间嵌套的页面*/}
{this.props.children}
<TabBar menu={menu} tabbarIndex={tabbarIndex} badge={badge} onChange={this.handleChange} />
</div>
);
}
componentDidMount() {
dd.biz.navigation.setTitle({ title:'Home' })
}
}
PageLogic.jsx
import { apiSync } from 'utils'
import PageConst from './PageConst';
export default {
defaults(props) {
return { empty: true, loading: false, ...PageConst,
tabbarIndex: 0,
}
},
setTabbarIndex( ctx, data ) {
ctx.setState({ tabbarIndex:data })
},
};
PageConst.js
export default {
menu: [
{"title":"导航", "icon":"nav", "path":"/home/nav" },
{"title":"数据录入", "icon":"entry", "path":"/home/entry" },
{"title":"数据显示", "icon":"display", "path":"/home/display" },
{"title":"反馈", "icon":"feedback", "path":"/home/feedback" },
{"title":"其它", "icon":"other", "path":"/home/other" }
],
}
我添加了以上路径的文件,如display
import React, { Component } from 'react'
// other import
export default class displayextends Component {
render(){
return (<div>
这是一个页面
</div>
)
}
}
为什么tab切换没有内容