GithubHelp home page GithubHelp logo

Comments (8)

Gcaufy avatar Gcaufy commented on May 17, 2024 11

@jiayx
如果当前组件是page,那么this.$parent是$app
如果当前组件是component, 那么this.$parent是父层component,this.$root是顶层的page,所以你可以这么写this.$root.$parent

另外还有一种方法:wepy.$instance 也可以

from wepy.

delayhsiao avatar delayhsiao commented on May 17, 2024 1

@jiayx 怪github,给我推邮件……我也不想的(摊手)

from wepy.

Gcaufy avatar Gcaufy commented on May 17, 2024

this.$wxapp 可以取到app
所以this.$wxapp.globalData 就是你定义在 app里面的globalData

from wepy.

jiayx avatar jiayx commented on May 17, 2024

我在测试的时候发现其他页面里 this.$wxapp.globalData 取不到,要这样才行 this.$wxapp.$app.globalData
是新版有改动吗?this.$wxapp 下只有方法,没有属性。

from wepy.

delayhsiao avatar delayhsiao commented on May 17, 2024

@jiayx 少年,你试试this.$parent.globalData

from wepy.

jiayx avatar jiayx commented on May 17, 2024

这个可以。。回复好快,多谢了!

from wepy.

jiayx avatar jiayx commented on May 17, 2024

@Gcaufy OK,了解了,回答的很详细,非常感谢!

from wepy.

silent-tan avatar silent-tan commented on May 17, 2024

$instance 的api我在官网文档找不到

from wepy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.