Skip to content

Commit

Permalink
fix(router component): 修复redirectTo tabbar暂时改用redirectTo
Browse files Browse the repository at this point in the history
  • Loading branch information
Littly committed Dec 12, 2018
1 parent 6883a7e commit b7c6b58
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 3 additions & 5 deletions packages/taro-components/src/components/tabbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,9 @@ class Tabbar extends Nerv.Component {
const { conf, router = {} } = this.props
function handleSelect (index, e) {
let list = this.state.list
router.navigateTo &&
router.navigateTo({
url:
(/^\//.test(list[index].pagePath) ? '' : '/') + list[index].pagePath
})
router.redirectTo && router.redirectTo({
url: (/^\//.test(list[index].pagePath) ? '' : '/') + list[index].pagePath
})
}
conf.borderStyle = conf.borderStyle || 'black'
let containerCls = classNames('weui-tabbar', {
Expand Down
12 changes: 7 additions & 5 deletions packages/taro-router/src/router/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class Route extends Component<RouteProps, {}> {
this.props.collectComponent(ref, this.props.k)
}

updateComponent () {
this.props.componentLoader()
updateComponent (props = this.props) {
props.componentLoader()
.then(({ default: component }) => {
let WrappedComponent = createWrappedComponent(component)
this.wrappedComponent = WrappedComponent
Expand All @@ -85,12 +85,14 @@ class Route extends Component<RouteProps, {}> {
}

componentWillReceiveProps (nProps, nContext) {
if (this.props.path !== nProps.path) this.updateComponent()

const lastMatched = this.matched
const nextMatched = this.computeMatch(nProps.currentLocation)

if (lastMatched === nextMatched) return
if (this.props.path !== nProps.path) {
this.updateComponent(nProps)
} else if (lastMatched === nextMatched) {
return
}

this.matched = nextMatched

Expand Down

1 comment on commit b7c6b58

@SmallRuralDog
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

支持,终于改了

Please sign in to comment.