Blogger Information
Blog 67
fans 0
comment 2
visits 72307
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
VUE3全局对象挂载
搁浅
Original
465 people have browsed it

main.js

  1. import { createApp } from 'vue'
  2. import App from './App.vue'
  3. import './registerServiceWorker'
  4. import router from './router'
  5. import store from './store'
  6. import ElementPlus,{ElLoading} from 'element-plus'
  7. import 'element-plus/dist/index.css'
  8. const app = createApp(App)
  9. app.use(store).use(router).use(ElementPlus).mount('#app')
  10. app.config.globalProperties.$ElLoading=ElLoading
  11. window.ElLoading=ElLoading//也可以挂到window对象里面

app.vue

  1. <template>
  2. <el-button type="primary" @click="overall"> As a service </el-button>
  3. </template>
  4. <script setup>
  5. import { getCurrentInstance } from 'vue';//因为vue3是组合API,所以要引入对应的(getCurrentInstance)
  6. const {proxy} = getCurrentInstance()
  7. const openFullScreen2 = () => {
  8. //const loading = window.ElLoading.service({
  9. const loading = proxy.$ElLoading.service({
  10. lock: false,
  11. text: 'Loading',
  12. background: 'rgba(0, 0, 0, 0.7)',
  13. })
  14. setTimeout(() => {
  15. loading.close()
  16. }, 1000)
  17. }
  18. </script>
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post