uniapp getApp()
时间: 2023-12-08 07:03:31 浏览: 129
小程序带值跳转 点击获得item元素的属性id或键值标识
The getApp() method in Uniapp returns the global app instance. This method is used to access the global app instance's properties and methods.
For example, to access the global app instance's properties, you can use the following code:
```javascript
const app = getApp()
console.log(app.globalData)
```
The code above retrieves the global app instance and logs its globalData property to the console.
Similarly, to call a method defined in the global app instance, you can use the following code:
```javascript
const app = getApp()
app.myMethod()
```
The code above retrieves the global app instance and calls a method named 'myMethod'.
阅读全文