js中字符型数值在判断比较时无需转换为数值型数据可直接按数值型数据使用,但是计算时应转换为数值型数据再进行使用

50 篇文章 3 订阅
21 篇文章 0 订阅

在QML中写function函数可以直接使用js语法!QML是支持的!
objdata.channel4U.channel是从配置文件中读到的数据的都是字符型数据,但是如果读到的是数值,在js中做判断时无需进行字符到数值的转换,会自动处理

function updateDataChannelB(id_channelB, objdata){
        switch(objdata.channel4U.channel)
        {
        case 0:
            id_channelB.currentIndex=0;
            console.debug("objdata.channel4U.channel:0 chinese:'无'")
            break;
        case 1:
            id_channelB.currentIndex=1;
            console.debug("objdata.channel4U.channel:1 chinese:'左1'")
            break;
        case 2:
            id_channelB.currentIndex=2;
            console.debug("objdata.channel4U.channel:2 chinese:'直1'")
            break;
        case 3:
            id_channelB.currentIndex=3;
            console.debug("objdata.channel4U.channel:3 chinese:'左2'")
            break;
        case 4:
            id_channelB.currentIndex=4;
            console.debug("objdata.channel4U.channel:4 chinese:'直2'")
            break;
        case 5:
            id_channelB.currentIndex=5;
            console.debug("objdata.channel4U.channel:5 chinese:'右'")
            break;
        }
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值