小程序使用switchTab跳转带参数

1.当前页定义全局变量,并给变量赋值

<script>
    // 定义全局变量
    const app = getApp();
    createPage({...
selectCounty(county) {
                app.cityName = county.name;
                wx.switchTab({
                    url: 'shop-list'
                });
            }

2.跳转页shop-list 定义全局变量,在onShow()中获取值

<script>
    // 定义全局变量
    const app = getApp();
    createPage({...
 onShow(){  
         this.cityName = app.cityName;
    },
发布了32 篇原创文章 · 获赞 11 · 访问量 11万+

猜你喜欢

转载自blog.csdn.net/jinxi1112/article/details/103295220
今日推荐