咱們測試使用App.vue頁面
一.先把js文件放到項目中html
二.引入jquery文件vue
在<script>...</script>代碼段中引入,放置在頭部(注意import後面有一個空格)
import '../utils/niuniu/jquery-1.6.4.min.js'
注意,若是不加 /* eslint-disable*/ ,那麼在開啓ESLint時,會報如下錯誤信息,加上則能夠免除驗證
三.編寫文件,測試jqueryjquery
文件完整信息以下
<template> <div id="app"> <img src="./assets/logo.png"><br/> <input type="text" name="user" id="user" placeholder="請輸入信息" /><br/> <span id="msg"></span> <!-- <router-view/> --> </div> </template> <script> /* eslint-disable*/ import '../utils/niuniu/jquery-1.6.4.min.js' import { Script } from 'vm'; export default { name: 'App', created () { console.log($('#user')) } } $(function() { // 綁定jquery處理事件,動態監聽文本框內容變化 $('#user').bind("input propertychange",function(event){ $('#msg').html('文本框裏的內容是:' + this.value) }) }) </script> <style> #app { font-family: 'Avenir', Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-align: center; color: #2c3e50; margin-top: 60px; } </style>
查看效果,文本框輸入內容,可實時顯示出輸入的信息,說明jquery引用成功:web