0
点赞
收藏
分享

微信扫一扫

【UI自动化测试技术】自动化测试研究:Python+Selenium+Pytest+Allure,详解UI自动化测试,iframe、窗口等控件切换(精)(五)

app.json

{
  "usingComponents": {
    "auth":"/components/auth/auth"
  }
}

app.js

App({
 globalData:{//定义全局变量
    isLoad:false
 }
})

index.wxml

<button type="default" bind:tap="inLoad">登入</button>

<button type="primary" bind:tap="outLoad">退出登入</button>


<auth isLoad="{{isLoad}}"><!-- 传输数据 -->
  <view class="tip">
  登入以后可以查看的内容
  </view>
</auth>

index.wxss

.tip{
  font-size: 60rpx;
  color:palegreen; 
  margin-top: 200rpx;
  padding: 0rpx 30rpx;
  background-color: bisque;
}

index.js

Page({
  data:{
    isLoad:false
  },
  //登入
  inLoad(){
    //修改全局变量为true
    const app=getApp()
    app.globalData.isLoad=true
    //console.log(app.globalData.isLoad)
    
    this.setData({//修改页面数据
      isLoad:app.globalData.isLoad
    })

  },

  //退出登入
  outLoad(){
    const app=getApp()
    app.globalData.isLoad=false
    //console.log(app.globalData.isLoad)

    this.setData({
      isLoad:app.globalData.isLoad
    })
  }
})

温馨提醒,以下组件不是页面,请勿建错
auth.wxml

<slot wx:if="{{isLoad}}"></slot>

auth.js

Component({
  behaviors: [],
  properties: {
    isLoad: {//接收数据
      type: Boolean,
      value: false
    }
  },
  lifetimes: {
    created() {

    },
    attached() {
     
    },
    moved() {

    },
    detached() {

    },
  methods: {
    
  }
}
})


  

在这里插入图片描述

举报

相关推荐

0 条评论