uni-app设置小程序的全局变量

2021-01-24 09:53:33

参考地址 uni-app ---小程序的全局变量

在使用uni-app开发的时候,有需要用到一些全局的变量,这些变量想要在其他的很多页面中使用

所以

app.vue

<script>	export default {		onLaunch: function() {			console.log('App Launch')							},		globalData:{			systemInfo: uni.getSystemInfoSync()		},		onShow: function() {			console.log('App Show')		},		onHide: function() {			console.log('App Hide')		}	}</script><style>	/*每个页面公共css */</style>

在需要用到的页面中

  1. <script>

  2. let app  = ''

  3. export default {

  4. data() {

  5. return {

  6. }

  7. },

  8. onLoad() {

  9. app = getApp()

  10. console.log(app.globalData.systemInfo)

  11. },

  12. methods: {

  13. }

  14. }

  15. </script>



  • 2017-11-10 00:06:15

    CORS: credentials mode is 'include'

    XMLHttpRequest cannot load http://localhost/Foo.API/token. The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'http://localhost:5000' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

  • 2017-11-19 00:17:51

    Java如何获取Date的“昨天”与“明天”示例代码

    最近在做项目的时候用到Date和Calendar比较多,而且用到的方式也比较全,突然想到一个问题,Java如何获取Date的"昨天"与"明天",也就是前一天和后一天呢?思考后写出了方法,想着万一以后用到,就总结出来,也方便有需要的朋友们参考借鉴,下面来一起看看吧。

  • 2017-11-23 02:00:51

    js 分页插件twbs-pagination

    ​cdn地址 http://www.bootcdn.cn/twbs-pagination/ 官网地址 可以在cdn地址上面查看到