Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

taro3 this.$scope无效 #7741

Closed
h025 opened this issue Sep 25, 2020 · 3 comments
Closed

taro3 this.$scope无效 #7741

h025 opened this issue Sep 25, 2020 · 3 comments
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@h025
Copy link

h025 commented Sep 25, 2020

相关平台

微信小程序

小程序基础库: 2.12.2
使用框架: React

复现步骤

import React, { Component } from 'react'
import { View } from '@tarojs/components'

class Index extends Component {
  componentDidMount(): void {
    console.log(this.$scope); // undefined
  }

  render() {
    return (
      <View/>
    )
  }
}

export default Index

期望结果

输出页面或者组件小程序原生作用域

实际结果

undefined

环境信息

  Taro CLI 3.0.6 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 10.16.3 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.17.3 - C:\Users\fen\AppData\Roaming\npm\yarn.CMD
      npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Sep 25, 2020
@DBvc
Copy link
Contributor

DBvc commented Sep 26, 2020

要用getCurrentInstance().page

迁移指南里有说明
http://taro-docs.jd.com/taro/docs/migration

@huiqiangSD
Copy link

@yoyo837
Copy link
Contributor

yoyo837 commented Oct 20, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
None yet
Development

No branches or pull requests

5 participants