This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
<template>
<view class="network-print-page">
<button type="primary" @tap="linkPrint">连接打印机</button>
</view>
</template>
<script setup>
uni.onSocketOpen(function (res) {
console.log('WebSocket连接已打开!');
});
function linkPrint () {
uni.connectSocket({
url: 'ws://192.168.1.15',
method: 'CONNECT',
success: (res) => {
console.log('连接打印机成功', res)
},
fail: (error) => {
console.log('连接打印机失败', error)
}
})
</script>
<style lang="scss">
</style>