new-uvue-page-1.uvue 2.6 KB
Newer Older
Y
init  
yurj26 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
<template>
    <view class="root">
        <view class="page-body">
            <view class="new-page__text-box">
                <text class="new-page__text">从上个页面接收到参数:{{data}}</text>
            </view>
           <view class="new-page__color" @click="changeColor" :style="{backgroundColor:stateData.currentColor}">
                <text class="new-page__color-text">点击改变颜色</text>
            </view>
            <view class="new-page__text-box">
                <text class="new-page__text">点击上方色块在页面之间进行通讯</text>
            </view>
            <view class="new-page__button">
                <button class="new-page__button-item" @click="navToUvue">跳转UVUE页面</button>
                <button class="new-page__button-item" @click="navToVue">跳转VUE页面</button>
            </view>
        </view>
    </view>
</template>
<script lang="ts">
    import { State, state, setColorIndex } from '@/store/index.uts'
    export default {
        data() {
            return {
                data: '',
                stateData: state as State
            }
        },
        methods: {
            changeColor() {
                setColorIndex(state.colorIndex > 1 ? 0 : state.colorIndex + 1)
            },
            navToUvue() {
                uni.navigateTo({
                    url: 'pages/API/navigator/new-page/new-uvue-page-2'
                })
            },
            navToVue() {
                uni.showToast({
                    icon: 'none',
                    title: '暂不支持'
                })
                // uni.navigateTo({
                //     url:'new-vue-page-2'
                // })
            }
        },
        onLoad(e: Map<string, string>) {
            // TODO 类型后续会做调整
            this.data = e['data']!
        }
    }
</script>
<style>
    .new-page__text {
        font-size: 14px;
        color: #666666;
    }

    .root {
        flex-direction: column;
    }

    .page-body {
        flex: 1;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        padding-top: 50px;
    }

    .new-page__text-box {
        padding: 20px;
    }

    .new-page__color {
        width: 200px;
        height: 100px;
        justify-content: center;
        align-items: center;
    }

    .new-page__color-text {
        font-size: 14px;
        color: #FFFFFF;
        line-height: 30px;
        text-align: center;
    }

    .new-page__button-item {
        margin-top: 15px;
        width: 300px;
    }
</style>