如何在vue中动态加载组件

时间:2017-08-02 01:44:45

标签: vue.js vuejs2 vue-component

GenericArray<Integer> arr = new GenericArray<>(Integer.class, 100); 

我有两个组件<template> <div> <v-container fluid id="main"> <v-card class="white lighten-4 elevation-3"> <li v-for="stop in stop_name_arr"> {{stop}} </li> <direct_bus_travel_time_in_between_stops> </direct_bus_travel_time_in_between_stops> <direct_bus_travel_distance_in_between_stops> </direct_bus_travel_distance_in_between_stops> </v-card> </v-container> </div> </template> &amp;完全执行direct_bus_travel_time_in_between_stops后加载direct_bus_travel_distance_in_between_stops

有什么办法可以在我希望加载组件时动态地将组件附加到函数中来加载它?

1 个答案:

答案 0 :(得分:6)

我非常认为您可以使用meta component标记,该标记异步加载传递给is属性的给定组件。

以下是代码:

<component is="direct_bus_travel_time_in_between_stops" > </component> <component is="direct_bus_travel_time_in_between_stops" > </component>

您可以在此标记中添加要加载的条件的函数/事件。 我认为此链接会有所帮助 - https://vuejs.org/v2/guide/components.html#Dynamic-Components 其中描述了动态使用的绑定组件

希望我的方法对你有用!