vue解决组件渲染延迟报错_在渲染组件之前解决您的路线的依赖性

vue解决组件渲染延迟报错

Vue解析 (Vue-resolve)

A VueJS (2.x) / Vue-router plugin that resolves dependencies for routes before entering.

一个VueJS(2.x)/ Vue-router插件,可在进入之前解决路由的依赖关系。

这是什么? (What is this?)

A plugin that reads a meta.resolve property on your component's route and resolve it (as a promise) before serving the route.

一个插件,它在组件的路由上读取meta.resolve属性,并在服务该路由之前对其进行解析(作为承诺)。

安装 (Install)

Install from npm:

从npm安装:

npm install vue-resolve --save

or from yarn:

或从纱线:

yarn add vue-resolve

(Example)

...
import VueResolve from 'vue-resolve';

const router = new VueRouter({
    routes: [{
        path: '/',
        component: mycomp,
        meta: {
            resolve: {
                mydata() {
                    return axios.get('/api/data');
                }
            }
        }
    }]
});

Vue.use(VueResolve, {
    router,
    dataProperty: 'data',
});

new Vue({
    ...
    router,
});

Important:

重要:

For reactivity please make sure to define the data properties your route is going to populate in your component, so Vue can keep track of changes after the routes resolves. (e.g. on the mycomp component, must exist a mydata data)

对于React性,请确保定义要在组件中填充路线的数据属性,以便Vue可以在路线解析后跟踪更改。 (例如在mycomp组件上, 必须存在一个mydata数据)

翻译自: https://vuejsexamples.com/resolve-dependencies-for-your-routes-before-rendering-the-component/

vue解决组件渲染延迟报错

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值