zoukankan      html  css  js  c++  java
  • vue取自动生成的数组中单个元素的值

    直接上代码:

    1.add.vue页面

    <view class="" v-for="(item,i) in detailTimePricesyd" :key="item">
          <!-- 时段/价格 -->
          <text class="uuu" v-if="item.salePrice!=0">{{i18n.SBD_Period_Price}}</text>
          <view :class="acb" v-if="item.salePrice!=0">
                <view class="sss">
                      <input class="uni-input" type="number" @input="onkeyInput" :data-type="'beginTime'+'-'+i" :v-model="'beginTime'+i"
                           maxlength="2" :value="item.beginTime" :name="'beginTime'+'-'+i" placeholder=" " />
                </view>
                <text class="szz">--</text>
                <view class="sss">
                      <input class="uni-input" type="number" @input="onkeyInput" :data-type="'endTime'+'-'+i" :v-model="'endTime'+i"
                           maxlength="2" :value="item.endTime" :name="'endTime'+'-'+i" placeholder=" " />
                </view>
                <!---->
                <text class="szz">{{i18n.SBD_Hour}}</text>
                <view class="ssl">
                      <input class="ppi" type="number" maxlength="5" :value="item.salePrice"
                          :name="'salePrice'+'-'+i" placeholder=" " />
                </view>
                <image src="../../static/img/sta/sc_h.png" @click="deleteSw(i)" :class="ssh"></image>
          </view>
          <text class="hx" v-if="item.salePrice!=0"></text>
    </view>
     

    2.在method方法里拿单个beginTime数据

    onkeyInput(e) {
                    let type = e.currentTarget.dataset.type
                    let from = 0;
                    let to = 20;
                    for (; from < to; from++) {
                        if (type == 'beginTime-'+from) {
                            let beginTime0 = e.target.value
                            if (beginTime0 > 24) {
                                uni.showToast({
                                    icon: 'none',
                                    title: this.SBD_greater_than_24
                                });
                                return
                            }
                            if (beginTime0 < 0) {
                                uni.showToast({
                                    icon: 'none',
                                    title: this.SBD_greater_than_0
                                });
                                return
                            }
                        }
                        if (type == 'endTime-'+from) {
                            let endTime0 = e.target.value
                            if (endTime0 > 24) {
                                uni.showToast({
                                    icon: 'none',
                                    title: this.SBD_greater_than_24
                                });
                                return
                            }
                            if (endTime0 < 0) {
                                uni.showToast({
                                    icon: 'none',
                                    title: this.SBD_greater_than_0
                                });
                                return
                            }
                        }
                    }
                },
                

     在onkeyInput方法里能拿到单个beginTime跟0和24比较做出提示

  • 相关阅读:
    国行ME525+(2.3.6)手机系统的备份方法
    JS定时刷新页面及跳转页面
    Webservice数据迁移
    SQL表A更新和表B同步
    C#面试题3
    移动互联
    新闻内容翻页
    教你怎么把服务器上的数据库备份到本地计算机
    asp.net性能优化
    sql2005数据库备份—sql语句
  • 原文地址:https://www.cnblogs.com/chenyangjava/p/15351974.html
Copyright © 2011-2022 走看看