Get the App
SLTechnology News&Howtos  ›  Development  › 

How to introduce external js into Vue.js

Shulou Source: shulou.com Published: 2022-06-01 21:50:10 10月23日 Update

This article mainly introduces how to introduce the relevant knowledge of external js in Vue.js, the content is detailed and easy to understand, the operation is simple and fast, and it has a certain reference value. I believe you will have something to gain after reading this article on how to introduce external js in Vue.js. Let's take a look.

1. External file config.js

Method 1:

/ / definition of constant const config = {definition of baseurl:' http://172.16.114.5:8088/MGT2'}// function function formatXml (text) {return text} / / Export {constant name, function name} export {config,formatXml}

Method 2:

/ / definition of constant export const config = {definition of baseurl:' http://172.16.114.5:8088/MGT2'}// function export function formatXml (text) {return text}

two。 Introduce constants and methods in config.js

We use this method to implement our file introduction, the code is as follows:

Import {config,formatXml} from'.. / config'// remember to put {} curly braces

3. Use the methods in config.js

Besides the above two methods, we can also use the methods in config.js. The code is as follows:

FormatXml () / / there is no need to add the this keyword and so on. This is the end of the article on "how to introduce external js in Vue.js". Thank you for reading! I believe you all have a certain understanding of "how to introduce external js into Vue.js". If you want to learn more, you are welcome to follow the industry information channel.

Tags: Method constant function knowledge code content file article two value key keyword parenthesis easy to operate article easy to understand more see industry information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology NVidia Microsoft Shulou Tech Info Redmi