zoukankan      html  css  js  c++  java
  • 小程序(1)

    不同页面传值问题

    wxml

    <view class="banci_left_bottom">
        <picker bindchange="bindCitycarChange_left" value="{{city_car_leftIndex}}" range="{{city_car_left}}">
          <view class="">{{city_car_left[city_car_leftIndex]}}</view>
        </picker>
    </view>
    <view class="banci_right_bottom">
        <picker bindchange="bindCitycarChange_right" value="{{city_car_rightIndex}}" range="{{city_car_right}}">
          <view class="">{{city_car_right[city_car_rightIndex]}}</view>
        </picker>
    </view>

    index.js

    Page({
      data : {
        city_car_left: ["上海浦东", "香港", "澳大利亚", "安徽"],
        city_car_leftIndex: 0,
        city_car_right: ["上海浦东", "香港", "澳大利亚", "安徽"],
        city_car_rightIndex: 1
      }
    })

    然后通过 navigator里面的url进行传参

     <navigator url="../pay/pay?code={{city_car_leftIndex}}&id={{city_car_rightIndex}}">    //用?进行传参   用&把所传的参数隔开
          <button class="weui-btn" type="primary" style="background-color:#FFCE39;color:black;">立即预约</button>
     </navigator>

    最后在接受参数的页面对接受到的参数进行处理

    onLoad: function (options) {   //options 是包含url地址中参数的对象,可以直接 点(.) 获取
        if (options.code){
          this.setData({
            city_car_leftIndex: options.code,
            city_car_rightIndex: options.id
          })
          console.log(options.code)
          console.log(options.id)
        }
      }

     

    预约页

    支付页

  • 相关阅读:
    array.prototype.slice.call(arguments)
    axios 的坑
    Cannot read property 'range' of null
    IDEA导入Eclipse的JavaEE项目详细步骤链接
    使用 yarn 安装时,报错node_modules ode sass:Command failed.
    axios post请求非json传参设置
    vue-cli 3.x跨域配置
    idea错误: 找不到或无法加载主类
    Git 上传新项目
    Windows下生成SSH密钥
  • 原文地址:https://www.cnblogs.com/colaman/p/7243952.html
Copyright © 2011-2022 走看看