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比较做出提示

  • 相关阅读:
    CentOS 6.2安装Darwin Streaming Server
    流媒体技术笔记(协议相关)
    流媒体技术笔记(视频编码相关)
    CentOS6.2下编译mpeg4ip
    用popen函数操作其它程序的输入和输出
    给centos6.2安装yum源
    启动新进程(fork和exec系列函数实现)
    扩展Asterisk1.8.7的Dialplan Applications
    源码安装ffmpeg(带libx264)
    扩展Asterisk1.8.7的AMI接口
  • 原文地址:https://www.cnblogs.com/chenyangjava/p/15351974.html
Copyright © 2011-2022 走看看