Tutorial on using jQuery and Bootstrap in Vue CLI3.0 (detailed steps)
This article brings you a tutorial (detailed steps) on using jQuery and Bootstrap in Vue CLI3.0. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you. .
The use of jQuery and Bootstrap in Vue is not particularly in line with Vue’s native writing method, but it is sometimes used, so I put my import settings for your reference.
Introducing jQuery and Bootstrap into Vue CLI2.0 requires setting up many configuration items. There are many methods on the Internet, so I won’t repeat them here. Go directly to the Vue CLI3.0 configuration steps.
Step one: Install jQuery, Bootstrap, popper.js dependencies.
popper.js is used to display pop-up windows, prompts, and drop-down menus in Bootstrap, so it needs to be introduced.
npm install jquery bootstrap@3 popper.js --save
Note: The bootstrap@3 above refers to installing the third version of Bootstrap. If the @3 symbol is not added, the fourth version will be installed by default.
Step 2: Configure main.js
Introduce Boostrap Please see the configuration file.
//main.js import Vue from "vue"; import App from "./App.vue"; import router from "./router"; import store from "./store"; //在这里引入 bootstrap。默认只引入 bootstrap 中的 js,css 需要另外引入,我的 bootstrap.ss 在APP.vue中引入的 import "bootstrap"; //也可以在这里引入 bootstrap.css ; //import "bootstrap/dist/css/bootstrap.css"; Vue.config.productionTip = false; new Vue({ router: router, store: store, render: h => h(App) }).$mount("#app");
The configuration of my APP.vue just introduces bootstrap.css, and the code is for reference only.
<style> // 因为我的 bootstrap 文件经过了我自己的调整,所以单独放在 assets 文件夹中做单独引入。 //如果你只是想使用原生的 bootstrap,直接在 main.js 中引入 css 文件即可。 @import "./assets/css/bootstrap.css"; </style>
Step 3: Configure the vue.config.js file
All configurations in Vue CLI3.0 are in the vue.config.js file, you are here Once configured, the scaffolding will automatically use your configuration to overwrite the default configuration.
If there is no vue.config.js file in your project, please create a new vue.config.js file in the same directory as the package.json file. The specific configuration in the file is as follows:
const webpack = require("webpack"); module.exports = { //configureWebpack 是Vue CLI3.0 中用于配置 webpack 插件参数的地方,你在这里设置,会新建或者覆盖 webpack 默认配置。 //webpack ProvidePlugin 的含义是创建一个全局的变量,使这个变量在 webpack 各个模块内都可以使用。这里的配置含义是创建 '$'、'jQuery'、'window.jQuery' 三个变量指向 jquery 依赖,创建 'Popper' 变量指向 popper.js 依赖。 configureWebpack: { plugins: [ new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery', 'window.jQuery': 'jquery', Popper: ['popper.js', 'default'] }) ] } }
Step 4: Specific usage example
I made a tooltip example, and the tooltip will appear when the mouse is placed on it Tip
//template <template> <div> <button>Tooltip on left</button> <button>Tooltip on top</button> <button>Tooltip on bottom</button> <button>Tooltip on right</button> </div> </template> <script> export default { name: "componentsTooltips", mounted: function() { //在页面加载完毕后初始化 tooltip, 相当于$(function(){ $('[data-toggle="tooltip"]').tooltip(); } $('[data-toggle="tooltip"]').tooltip(); } }; </script>
If eslint reports an error, please set the .eslintrc.js file.
module.exports = { env: { node: true, jquery: true } };
My test results are as follows:
The above is the detailed content of Tutorial on using jQuery and Bootstrap in Vue CLI3.0 (detailed steps). For more information, please follow other related articles on the PHP Chinese website!

JavaScript's application in the real world includes front-end and back-end development. 1) Display front-end applications by building a TODO list application, involving DOM operations and event processing. 2) Build RESTfulAPI through Node.js and Express to demonstrate back-end applications.

The main uses of JavaScript in web development include client interaction, form verification and asynchronous communication. 1) Dynamic content update and user interaction through DOM operations; 2) Client verification is carried out before the user submits data to improve the user experience; 3) Refreshless communication with the server is achieved through AJAX technology.

Understanding how JavaScript engine works internally is important to developers because it helps write more efficient code and understand performance bottlenecks and optimization strategies. 1) The engine's workflow includes three stages: parsing, compiling and execution; 2) During the execution process, the engine will perform dynamic optimization, such as inline cache and hidden classes; 3) Best practices include avoiding global variables, optimizing loops, using const and lets, and avoiding excessive use of closures.

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

JavaScript's applications in the real world include server-side programming, mobile application development and Internet of Things control: 1. Server-side programming is realized through Node.js, suitable for high concurrent request processing. 2. Mobile application development is carried out through ReactNative and supports cross-platform deployment. 3. Used for IoT device control through Johnny-Five library, suitable for hardware interaction.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Notepad++7.3.1
Easy-to-use and free code editor

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver CS6
Visual web development tools