uni-app cannot distinguish between global variables this, uni, $u, vm, uni.$u, this.$u

 The project introduces uview and points all modules of uview to the uniapp global variable uni

  uni.$u=$u

 On the login page, or APP.vue prints the following variables:

this, uni, $u, vm, uni.$u, this.$u

 //  this,$u,vm,uni,  this.$u, uni.$u全局变量说明
    console.log(">>this", this)
    console.log(">>uni", uni)
    console.log(">>this===uni", this === uni) //false
    console.log(">>this.$u ", this.$u)
    console.log(">>uni.$u ", uni.$u)
    console.log(">>this.$u===uni.&u", this.$u === uni.$u) //ture

    try {//$u is not defined
      console.log(">>$u ", $u)
    } catch (e) {
      console.log(e)
    }
    try { //vm is not defined
      console.log(">>this.vm", this.vm)
      console.log(">>vm ", vm)
    } catch (e) {
      console.log(e)
    }

operation result

$u     is where uview is mounted on uni, which makes it convenient to use uni to operate uview components. 

The uni.object  is a uni-app framework instance.

this.  In the .vue page, the corresponding is the current vue instance object.

this.$u and uni.$u     are the same object on the vue page, pointing to uview

Guess you like

Origin blog.csdn.net/LlanyW/article/details/132522228