页面局部使用vue等框架其它部分用JQuery进行交互

ops/2024/10/24 17:56:34/

这个需求是原有django在网页需要定制一个人员签到信息。状态有三种,在岗,下班。好吧两种。但是你想 1,1.这是两次、共四个可能,00, 10,01,11.其中00是在家。10是在岗。01是。不签到只签退,算是异常, 11 最后和00是一样的。所以有三种状态,三个色表示,全部的人员信息。其中还有搜索之类。做成了VUE在一个单文件。需要借用信息并显示出来。
在html中有总的树状菜单。点击就让vue加载一次。vue会从接口或点到时传入window的全局变量接到数据。
具体就是一样一个流程。有利于用vue集成到原有系统中实现一个功能。
下面是普通在一直在用的点数字vuetkyc

<script >
import { ref,watch ,getCurrentInstance } from 'vue'import { useHttp } from './http';const  count =ref(0)const parentmsg = ref(String("dsafd"))export default {props: {// 基本类型验证msg3: {type: String,default: '默认标题'},},mounted() {window.msgproxg=this},setup() {const users = ref([]);const fetchUsers = async () => {fetch('/api/'+parentmsg.value).then((response) => {if (response.ok){return response.json();}}).then((data) => {if (data)console.log(data["222"]);}).catch((error) => {console.error('Fetch error:', error);});};watch(parentmsg, async (newValues, oldValues) => {console.log('parentmsg changed:', newValues, oldValues);if  (newValues){fetchUsers();}});const { loading, data, error, get } = useHttp();return {count,parentmsg,get,data,loading,fetchUsers,error,changemsg() {parentmsg.value=" 1222233333"}};},};
</script><template><h1 ref="into"></h1>
{{ msg3 }}<div class="card"><button type="button" ref="btn" @click="count++">count is {{ count }}</button><p>{{ parentmsg }}   Edit <code>components/HelloWorld.vue</code> to test HMR</p></div>
</template><style scoped>
.read-the-docs {color: #888;
}
</style>还算这样吧 in  mounted 
VUE2```bashwindow.msgproxg=this
VUE3```bash
import { ref,onMounted,computed,getCurrentInstance } from 'vue';onMounted(() => { fetchUsers()window.myvue=getCurrentInstance()}

然而
https://blog.csdn.net/jieyucx/article/details/134030633

J-JQuery, 外部
V- VUE ,内部

V中有

. Element

<h1 ref="into"></h1>

J中 操作普通元素。

window.msgproxg.$refs.meme.innerHTML=“标题”

. 事件
V

 <button type="button" ref="btn" @click="count++">count is {{ count }}</button>

J 中

window.msgproxg.$refs.btn.click()

上面是refs在两个例子
, 方法及监听变化
V中

     watch(parentmsg, async (newValues, oldValues) => {console.log('parentmsg changed:', newValues, oldValues);if  (newValues){fetchUsers();}});changemsg(value) {parentmsg.value= value}

J中,因为只接改变内部变量,暂未找到方法,所以使用changmsg。而没有只接使用,异步方法在调用。这是因为我也不明白,只接使用,会有什么不可想像的事。所以经过这一圈 watch。 function, 还有async的fecthuser
只有一行,获取参数2344的API数据

window.msgproxg.changemsg("2344")

介绍结束J-V结束。
另外V到J在控制,感觉除了window和,document应该可以做一些吧。就是另一个话题了。

在这里插入图片描述


http://www.ppmy.cn/ops/128117.html

相关文章

华为CE交换机telnet登录失败故障的排查方法

检查网络状态 操作步骤 1、执行命令ping xxx.xxx.xxx.xxx(目的IP网段) 根据报文是否丢包确认是否可以访问该设备&#xff0c;网络不通请检查组网及网络地址、静态路由等相关配置。 检查VTY通道是否已占满&#xff1f; 操作步骤 1、在任意视图下&#xff0c;执行命令displ…

顺丰员工砸了京东广告牌获特殊贡献奖,京东:报警了

大家好&#xff0c;我是鸭鸭&#xff01; 大家对商战的印象&#xff0c;在见过当当抢公章&#xff0c;开水浇发财树&#xff0c;评论区阴阳怪气等一系列真实商战后&#xff0c;已经对各大公司的“有病”行为有了一定的心理准备。 没想到&#xff0c;今天鸭鸭又看到了新的商战…

数据结构 | 第一章 | 线性表 | 静态和动态顺序表

静态顺序表和动态顺序表 一、基础知识 概念&#xff1a;线性表&#xff08;linear list&#xff09;是n个具有相同特性的数据元素的有限序列。 线性表是一种在实际中广泛使 用的数据结构&#xff0c;常见的线性表&#xff1a;顺序表、链表、栈、队列、字符串 线性表在逻辑上是…

【Golang】关于Gin框架请求参数的获取

✨✨ 欢迎大家来到景天科技苑✨✨ &#x1f388;&#x1f388; 养成好习惯&#xff0c;先赞后看哦~&#x1f388;&#x1f388; &#x1f3c6; 作者简介&#xff1a;景天科技苑 &#x1f3c6;《头衔》&#xff1a;大厂架构师&#xff0c;华为云开发者社区专家博主&#xff0c;…

简易CPU设计入门:验证取指令模块

项目代码下载 还是请大家首先准备好本项目所用的源代码。如果已经下载了&#xff0c;那就不用重复下载了。如果还没有下载&#xff0c;那么&#xff0c;请大家点击下方链接&#xff0c;来了解下载本项目的CPU源代码的方法。 下载本项目代码 准备好了项目源代码以后&#xff…

OpenBayes 一周速览|即刻体验Depth Pro,0.3秒get深度图;超高清视频生成模型上线,帧率高达24fps

公共资源速递 This Weekly Snapshots &#xff01; 5 个数据集&#xff1a; SynthText 自然场景图像数据集 Caltech-101 物体识别图像数据集 BSDS500 轮廓检测与语义分割数据集 PKU-Market-Phone 手机屏幕表面缺陷分割数据集 Berkeley Cable Routing 多阶段机器人电缆任务…

集合相关:asList()和subList()方法的作用?

1.asList()方法 Arrays.asList(T... a)返回一个固定大小的列表&#xff0c;这个返回的列表的底层实现是一个final修饰的数组&#xff0c;其引用关系不能发生变化&#xff0c;并且它的大小也是固定的&#xff0c;可以修改和读取里面的元素值&#xff0c;但是不能添加或删除元素。…

u盘装win10系统提示“windows无法安装到这个磁盘,选中的磁盘采用GPT分区形式”解决方法

我们在u盘安装原版win10 iso镜像时&#xff0c;发现在选择硬盘时提示了“windows无法安装到这个磁盘,选中的磁盘采用GPT分区形式”&#xff0c;直接导致了无法继续安装下去。出现这种情况要怎么解决呢&#xff1f;下面小编分享u盘安装win10系统提示“windows无法安装到这个磁盘…