用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切換沒有內容