Mow*_*zer 11 javascript api dom polymer polymer-1.0
有人可以提供正确实施的例子dom-if吗?
官方文档没有提供正确使用的示例.(对不起,没有直接链接.必须使用左上角的菜单并选择dom-if).
这是我到目前为止所拥有的.显然,它不起作用.
<template>
...
<template is="dom-if" if="{{action}}=='Login'">
<!-- Also tried: if="{{action=='Login'}}" -->
<a href="#">Forgot password?</a>
</template>
...
</template>
Run Code Online (Sandbox Code Playgroud)
age*_*tmr 29
这很麻烦,但你必须这样做:
<template is="dom-if" if="[[_actionIsLogin(action)]]">
<a href="#">Forgot password?</a>
</template>
<script>
Polymer({
...
_actionIsLogin: function(action) {
return action === 'Login';
}
...
});
</script>
Run Code Online (Sandbox Code Playgroud)
明确创建返回无论是功能true还是false.