<template>
  <view class="container" @click="changeColor">
    <text>点击切换页面容器颜色</text>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        isChange: false,
        currentBackgroundColorContent: "" as any | null
      }
    },
    methods: {
      changeColor() {
        let pages = getCurrentPages()
        let page = pages[pages.length - 1]
        page.setPageStyle({ "backgroundColorContent": this.isChange ? "" : "red" })
        this.isChange = !this.isChange

        let pageJson = page.getPageStyle()
        this.currentBackgroundColorContent = pageJson["backgroundColorContent"]
      }
    }
  }
</script>

<style>
  .container {
    flex: 1;
    align-items: center;
    justify-content: center;
  }
</style>
