wechat_nuxt_001
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<style lang="scss" scoped>
|
||||
div.root-home {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
<template>
|
||||
<div class="root-home">
|
||||
<div>这里是首页了吗?是的,这里是首页,已经在页面上显示了</div>
|
||||
<div>
|
||||
<el-button @click="websockted发送消息" type="danger">websockted发送消息</el-button>
|
||||
</div>
|
||||
<xiao-zizi v-model:modelValue="data_msg"></xiao-zizi>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import {useWebSocket} from "@vueuse/core";
|
||||
import XiaoZizi from "~/components/xiao-zizi.vue";
|
||||
|
||||
let data_msg = ref(1);
|
||||
const counter = useState("counter", () => 0);
|
||||
const {data, send, close} = useWebSocket("wss://six.sixgou.com/room/xiaozizi/", {
|
||||
onMessage(_ws, event) {
|
||||
console.log("Message:", event.data, typeof event.data);
|
||||
console.log(JSON.parse(event.data));
|
||||
},
|
||||
});
|
||||
const websockted发送消息 = async (): Promise<void> => {
|
||||
send("websockted");
|
||||
};
|
||||
onUnmounted(() => {
|
||||
// close();//关闭连接,消除实例
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user