1. Global introduction of files
1. Define the shared components first
<script type="text/javascript"> // Define some common properties and methods const httpUrl = 'http://39.105.17.99:8080/' function commonFun() { ("Public Method") } // Expose these properties and methods export default { httpUrl, commonFun } </script>
2. Import where you need to use
<script> // Import shared componentsimport global from './' export default { data () { return { username: '', password: '', // Assign value use globalHttpUrl: } },
3. Use
<template> {{globalHttpUrl}} </template>
2. Introduce global variables and methods
1. Define the shared components as above
2. Introduce and copy to vue
// Import shared componentsimport global from './' = global
3. Use
export default { data () { return { username: '', password: '', // Use this variable to access it globalHttpUrl: } },
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.