国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

javascript - 小程式中字串的JSON資料如何轉(zhuǎn)換為Number類型
過去多啦不再A夢
過去多啦不再A夢 2017-05-18 10:51:21
0
2
801
/** index.js*/
var app = getApp()  
Page({  
    data: {  
        /**   
         * 頁面配置  
         */  
        winWidth: 0,  
        winHeight: 0,  
        // tab切換    
        currentTab: 0, 
                option1:[
          {value:"1",contant:"A:xxxx"},
          {value:"2",contant:"B:xxxx"},
          {value:"3",contant:"C:xxxx"},
          {value:"4",contant:"D:xxxx"}
        ],
        option2: [
          { value: "1", contant: "A:xxxx" },
          { value: "2", contant: "B:xxxx" },
          { value: "3", contant: "C:xxxx" },
          { value: "4", contant: "D:xxxx" }
        ], 
        option3: [
          { value: "1", contant: "A:xxxx" },
          { value: "2", contant: "B:xxxx" },
          { value: "3", contant: "C:xxxx" },
          { value: "4", contant: "D:xxxx" }
        ],
        option1Value:0,
        option2Value:0,
        option3Value:0,
    },  
    onLoad: function() {   swiperChange: function(e){
                var that = this;
        if(that.data.currentTab==0){
          that.setData({
            option1Value : e.detail.value,
            currentTab: 1 
          });
        }else if(that.data.currentTab==1){
          that.setData({
            option2Value : e.detail.value,
            currentTab: 2
          });
        }else if(that.data.currentTab==2){
          that.setData({
            option3Value : e.detail.value,
            currentTab: 3
          })
        } 
         }   


})  

<!-- index.wxml -->
                    <!-- 問題區(qū)域 -->
<view class="swiper-tab">    
    <view class="swiper-tab-list {{currentTab==0 ? 'on' : ''}}" data-current="0" bindtap="swichNav">第一題</view>    
    <view class="swiper-tab-list {{currentTab==1 ? 'on' : ''}}" data-current="1" bindtap="swichNav">第二題</view>    
    <view class="swiper-tab-list {{currentTab==2 ? 'on' : ''}}" data-current="2" bindtap="swichNav">第三題</view>      
</view>

                    <!-- 選項(xiàng)區(qū)域 -->
<swiper current="{{currentTab}}" class="swiper-box" duration="300" style="height:{{winHeight - 31}}px" bindchange="bindChange">    

                    <!-- 第一題選項(xiàng) -->    
    <swiper-item>    
      <radio-group bindchange="swiperChange">
        <label class="option" wx:for="{{option1}}">
          <radio value="{{item.value}}" />{{item.contant}}
        </label>
      </radio-group>   
    </swiper-item>    

                    <!-- 第二題選項(xiàng) -->    
    <swiper-item>    
      <radio-group bindchange="swiperChange">
        <label class="option" wx:for="{{option2}}">
          <radio value="{{item.value}}" />{{item.contant}}
        </label>
      </radio-group>   
    </swiper-item>  

                    <!-- 第三題選項(xiàng) -->    
    <swiper-item>    
      <radio-group bindchange="swiperChange">
        <label class="option" wx:for="{{option3}}">
          <radio value="{{item.value}}" />{{item.contant}}
        </label>
      </radio-group>   
    </swiper-item> 

     <swiper-item>    
        <view>{{score}}</view>
    </swiper-item>

以上是我的程式碼,想實(shí)現(xiàn)頁面中有三個題目,分別有四個不同分值的選項(xiàng),用戶選擇後直接彈出結(jié)果,但是儲存用戶選擇的選項(xiàng)的JSON資料是字串,請問如何轉(zhuǎn)換為數(shù)字類型?

過去多啦不再A夢
過去多啦不再A夢

全部回覆(2)
淡淡煙草味

雷雷

僅有的幸福

你存的時候是數(shù)字, parse出來就是數(shù)字...
現(xiàn)在你存的是字符串..
轉(zhuǎn)換的話
+e.detail.value 就行

最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板