NativeScript-Vue 2.0: Back to the Vueture (Webinar) is now on YouTube
v-view

v-view 指令允许您将当前元素的 View 设置为父属性。


<Child v-view:parentPropertyName />
<!-- same as: -->
<Child ~parentPropertyName />
<Child v-view:parentArrayPropertyName.array />
<!-- same as: -->
<Child ~parentArrayPropertyName.array />

例: <RadSideDrawer>

<RadSideDrawer> 组件是 Progress NativeScript UI 包的一部分。

<RadSideDrawer> 组件需要将 drawerContentmainContent 属性设置为 View 实例。使用 v-view 指令,您可以使用几行代码执行此操作:

<RadSideDrawer>
  <StackLayout ~drawerContent />
  <StackLayout ~mainContent />
</RadSideDrawer>

如果没有该 v-view 指令,您需要采用更乏味且容易出错的路线:

<RadSideDrawer ref="drawer">
  <StackLayout ref="drawerContent" />
  <StackLayout ref="mainContent" />
</RadSideDrawer>
{
  mounted() {
    this.$refs.drawer.nativeView.drawerContent = this.$refs.drawerContent.nativeView
    this.$refs.drawer.nativeView.mainContent = this.$refs.mainContent.nativeView
  }
}
Contributors