Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

想问下this.$router是哪里来的? #13

Open
cshenger opened this issue Sep 9, 2020 · 1 comment
Open

想问下this.$router是哪里来的? #13

cshenger opened this issue Sep 9, 2020 · 1 comment

Comments

@cshenger
Copy link

cshenger commented Sep 9, 2020

我目前基于最新的3.0.8的版本改造这个项目,但是node_detail.tsx中的$router是从哪里来的? 谢谢。

componentWillMount() {
    const { full_name } = this.$router.params; // 我不太懂这个$router是怎么来的,前端会报错
    Taro.setNavigationBarTitle({
      title: decodeURI(full_name),
    });
  }
@cshenger
Copy link
Author

好吧,3.0的版本接口改了,现在要这样用

import Taro, { getCurrentInstance } from "@tarojs/taro";

componentWillMount() {
    const { full_name } = getCurrentInstance().router.params;
    Taro.setNavigationBarTitle({
      title: decodeURI(full_name),
    });
  }

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant