码迷,mamicode.com
首页 > 移动开发 > 详细

uniapp位操作

时间:2020-04-19 13:18:29      阅读:79      评论:0      收藏:0      [点我收藏+]

标签:操作   bit   view   tar   receive   ext   data   buffer   ons   

<template>
<view>
<view >
<button v-on:click="osplateform">osplateform</button>
<text>test</text>
</view>
<button v-on:click="closesocket">SocketClose</button>
<button v-on:click="opensocket">opensocket</button>
<button @click="sendmsg">sendmessage</button>
<button @click="rcvmsg">receivemessage</button>
</view>
</template>
<script>
const buffer = new ArrayBuffer(7)
buffer[0]=0xF7
buffer[1]=0x02
buffer[2]=0x04
buffer[3]=0x08
buffer[4]=0x10
buffer[5]=0x20
buffer[6]=0x40
buffer[7]=0x80

const bitArray = new ArrayBuffer(7)
bitArray[0]=0x01
bitArray[1]=0x02
bitArray[2]=0x04
bitArray[3]=0x08
bitArray[4]=0x10
bitArray[5]=0x20
bitArray[6]=0x40
bitArray[7]=0x80

var buf=0x01
var cnt=1

export default {
data() {
return {
}
},
onLaunch() {
this.globalData.socket =io(‘http://localhost‘);
},

methods:{
osplateform(){

},
closesocket(){

},
opensocket(){

},
sendmsg(){
console.log("sending");
},
rcvmsg(){
if(cnt>7){
cnt=1
buf=0x01
}
else{
cnt=cnt+1
buf=buf<<1
}
console.log("buf: " + buf);
console.log("cnt: " + cnt);

for (var i = 0; i <= 7; i++) {
//console.log("for of i: " + i +"&"+(bitArray[i] & buffer[0]) + "bitArray"+bitArray[i]);
if((bitArray[i] & buffer[7])==bitArray[i])
{
console.log("第"+(i+1)+"位是On: ");
}
}
}
},
}
</script>

<style>

</style>

uniapp位操作

标签:操作   bit   view   tar   receive   ext   data   buffer   ons   

原文地址:https://www.cnblogs.com/omegasu/p/12730757.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!