当前位置:网站首页>Uni app implements global variables
Uni app implements global variables
2022-07-05 09:07:00 【Hang Hang Dad】
4、globalData
Applet can be used in App Statement above Global variables , But in Vue There is no ,uni-app In the App.vue Can be defined in globalData Attribute , Can also be used API Read and write this value .
This way supports vue and nvue Shared data . Is currently the nvue and vue A better way to share data .
1, Definition :App.vue Define methods or variables
<script> export default { globalData: { text: 'text' }, onLaunch: function() { console.log('App Launch') }, onShow: function() { console.log('App Show') }, onHide: function() { console.log('App Hide') } } </script> <style> /* Every page is public css */ </style>
2, Operation in page globalData The way
assignment :
getApp().globalData.text = 'test'
Value :
console.log(getApp().globalData.text)
Use cases :
import app from "../../App.vue" /// This sentence is more important You can try Delete and add this sentence
// there vm, Is that we are vue In the document this, So we can get it here vuex The variable of , Like what's in it token Variable
const install = (Vue, vm) => {
// This is a custom configuration parameter , See the above description for specific parameters
Vue.prototype.$u.http.setConfig({
baseUrl: app.globalData.apiUrl,
loadingText: 'loading...',
loadingTime: 300,
originalData: false, // Whether to return the original data of the server in the interceptor
loadingMask: true, // Exhibition loading When , Whether to give a transparent mask , Prevent touch penetration
// ......
});
边栏推荐
- Generate confrontation network
- Golang foundation -- map, array and slice store different types of data
- Rebuild my 3D world [open source] [serialization-1]
- 混淆矩阵(Confusion Matrix)
- Huber Loss
- 利用请求头开发多端应用
- 优先级队列(堆)
- MPSoC QSPI Flash 升级办法
- 什么是防火墙?防火墙基础知识讲解
- Ros- learn basic knowledge of 0 ROS - nodes, running ROS nodes, topics, services, etc
猜你喜欢
优先级队列(堆)
Introduction Guide to stereo vision (2): key matrix (essential matrix, basic matrix, homography matrix)
C#【必备技能篇】ConfigurationManager 类的使用(文件App.config的使用)
Introduction Guide to stereo vision (4): DLT direct linear transformation of camera calibration [recommended collection]
Programming implementation of ROS learning 5-client node
Count of C # LINQ source code analysis
Rebuild my 3D world [open source] [serialization-3] [comparison between colmap and openmvg]
RT thread kernel quick start, kernel implementation and application development learning with notes
[Niuke brush questions day4] jz55 depth of binary tree
Ros-10 roslaunch summary
随机推荐
12. Dynamic link library, DLL
notepad++
皮尔森相关系数
OpenFeign
图解网络:什么是网关负载均衡协议GLBP?
[code practice] [stereo matching series] Classic ad census: (6) multi step parallax optimization
Ros- learn basic knowledge of 0 ROS - nodes, running ROS nodes, topics, services, etc
资源变现小程序添加折扣充值和折扣影票插件
Return of missing persons
Rebuild my 3D world [open source] [serialization-1]
Jenkins Pipeline 方法(函数)定义及调用
Oracle advanced (III) detailed explanation of data dictionary
Solution to the problem of the 10th Programming Competition (synchronized competition) of Harbin University of technology "Colin Minglun Cup"
Introduction Guide to stereo vision (7): stereo matching
Mengxin summary of LIS (longest ascending subsequence) topics
Golang foundation - the time data inserted by golang into MySQL is inconsistent with the local time
信息與熵,你想知道的都在這裏了
Summary and Reflection on issues related to seq2seq, attention and transformer in hands-on deep learning
My experience from technology to product manager
AUTOSAR从入门到精通100讲(103)-dbc文件的格式以及创建详解