8***@qq.com
8***@qq.com
  • 发布:2018-12-19 13:58
  • 更新:2022-01-24 15:39
  • 阅读:2176

manifest使用页面js异步加载配置,里面的loading组件如何使用?

分类:uni-app

在manifest.json配置了如下的代码:
"h5": {
"async": {
"loading": "AsyncLoading", // 页面js加载时使用的组件(需注册为全局组件)
"error": "AsyncError", // 页面js加载失败时使用的组件(需注册为全局组件)
"delay": 200, // 展示 loading 加载组件的延时时间
"timeout": 5000 // 页面js加载超时时间(超时后展示 error 对应的组件)
}
},

然后在main.js引入:
import AsyncLoading from './components/asyncLoading.vue'

请求的时候,没有调用到loading??

是哪里出了问题???

2018-12-19 13:58 负责人:无 分享
已邀请:
Trust

Trust - 少说废话

1、组件名字是否正确
2、是否注册为全局组件

上传下完整的项目

  • 8***@qq.com (作者)

    在main.js已经注册全局了,名字也没写错

    2018-12-19 15:42

  • Trust

    回复 8***@qq.com:麻烦你去认真读一下 Vue 的组件规范,什么叫组件名。连 name 都没有声明,也就是没有写名字。https://cn.vuejs.org/v2/guide/components-registration.html

    2018-12-19 15:47

  • Trust

    回复 8***@qq.com:另外,上传项目的时候,麻烦上传完整的可以直接运行的,而不是某一个文件,这样根本没办法重现或定位问题。

    2018-12-19 15:48

8***@qq.com

8***@qq.com (作者)

asyncLoading代码

Trust

Trust - 少说废话

1、在 components 目录下新建组件,组件声明 name,比如叫 :loading
2、组件是没有 onLoad 等页面的生命周期的,组件遵循 Vue 规范的生命周期函数。
3、在 main.js 中注册 loading 为全局组件
4、在 Chrome 中测试,将网速调慢点,就可以看到效果。
5、这个是一个组件,也就是视图的内容,不是调用某个 API。
6、仔细看文档说明,这个是页面加载 JS 资源时显示的组件,而不是修改 API 相关的内容。

<template>  
    <view>  
        <text>loading.....................</text>  
    </view>  
</template>  

<script>  
    export default {  
        name: 'loading',  
        data() {  
            return {  

            };  
        }  
    }  
</script>  

<style>  

</style>
import Vue from 'vue'  
import App from './App'  

import loading from './components/loading.vue'  

Vue.component('loading', loading)  

App.mpType = 'app'  

const app = new Vue({  
    store,  
    ...App  
})  
app.$mount()
1***@qq.com

1***@qq.com

我按照这个方式操作,还是出不来,请问楼主解决这个问题了吗?

312860

312860 - 312860

怎么配置的啊 不生效啊

312860

312860 - 312860

loading 需要 用position-fixed

Lucassssss

Lucassssss

辛苦看下隔壁我的问题呀 https://ask.dcloud.net.cn/question/131107

1***@qq.com

1***@qq.com

就照Trust说的方法,没问题的

该问题目前已经被锁定, 无法添加新回复