登录  /  注册
博主信息
博文 67
粉丝 0
评论 2
访问量 69188
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
VUE3全局对象挂载
搁浅
原创
425人浏览过

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>
本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学