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-02-13 17:50:05

    cURL error 60: SSL certificate problem: unable to get local issuer certificate

    Drupal 8 version uses Guzzle Http Client internally, but under the hood it may use cURL or PHP internals. If you installed PHP cURL on your PHP server it typically uses cURL and you may see an exception with error Peer certificate cannot be authenticated with known CA certificates or error code CURLE_SSL_CACERT (60).

  • 2017-02-16 08:09:01

    HTML中PRE和p的区别

    pre 元素可定义预格式化的文本。被包围在 pre 元素中的文本通常会保留空格和换行符。而文本也会呈现为等宽字体。 <pre> 标签的一个常见应用就是用来表示计算机的源代码。

  • 2017-02-16 15:14:14

    动态加载js和css

    开发过程中经常需要动态加载js和css,今天特意总结了一下常用的方法。