Vue3 引入 jquery

通过 js包的方法 引入 jquery

当然也可以用  npm install jquery --save-dev  方法

但 引用 js包 方法 配置相对简单,在npm遇到问题时可采用此种方式

一.下载 jquery压缩包

官网下载:jquery.com/download/

二.在根目录下 public文件夹里的 index.html 中引入jquery
在 public 文件夹中新建 js 文件夹用来存放下载的 js 包

<script src="./js/jquery.min.js"></script>

三.在 package.json 中添加 eslintConfig 配置块 "jquery": true 否则会一直报错!!

注:末尾没有 逗号

"eslintConfig": {
    "root": true,
    "env": {
      "node": true,
      "jquery": true //新增这一行
 },

四、使用示例

html

<div id="localtime" class="hdtime">测试 jquery</div>

js

复制代码
mounted() {
    this.page_init();
},
methods: {
    page_init(){
       console.log($('#localtime').html()); 
    }
         
},
复制代码

 输出

 

 


 
posted @   海乐学习  阅读(1811)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
历史上的今天:
2017-05-24 chrome表单自动填充导致input文本框背景变成偏黄色问题解决
点击右上角即可分享
微信分享提示