Dart语言:Polymer - 使用视图 [英] Dart Language: Polymer - Working with views

查看:188
本文介绍了Dart语言:Polymer - 使用视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Dart开发我的第一个复杂应用程序,我发现一些麻烦,如何使用多个视图(我想开发的应用程序在一个页面内运行)。

I'm developing my first "complex" application on Dart and I'm finding some trouble on how to work with more than one view (I want to develop the application to run within a single page).

首先,我假设(使用Polymer)是正确的方法来处理应用程序的各种视图(或应用程序屏幕)。然而,如果不是,我想知道(当然)。而在应用程序屏幕,我在说什么像在Java中创建各种形式。

First of all, I'm assuming that this (using Polymer) is the right approach to work with various views (or "app screens") of the application. However, if it's not, I would like to know (of course). And by "app screens", I'm saying something like creating various forms in Java.

因此,例如,我有两个按钮在页面的顶部。当您单击第一个时,它显示一个带有用户注册区域的视图。当你点击第二个按钮,它显示一个视图与可编辑网格。

So, for instance, I have two buttons at the top of the page. When you click the first one, it shows a view with an user registration area. When you click the second button, it shows a view with an editable grid.

你能给我一些这个简单的应用程序的代码示例吗?

Could you give me some code example of this simple app?

推荐答案

您可以使用模板如果功能。

You could use the template if functionality.
This way views that are currently not active are automatically removed from the DOM and automatically inserted again when the model attribut changes.

<polymer-element name='app-element'>
  <template>
    <template if='{{appModel.view == 'view1'}}'>
      <view1></view1>
    </template>

    <template if='{{appModel.view == 'view2'}}'>
      <view2></view2>
    </template>
  </template>
  <script ...>
</polymer-element>

这篇关于Dart语言:Polymer - 使用视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆