uniapp位操作

寸阳分阴须爱惜,休负春色与时光。这篇文章主要讲述uniapp位操作相关的知识,希望能为你提供帮助。
< 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>
【uniapp位操作】< /style>

    推荐阅读