我正在尝试根据json的参数包含类,所以如果我有属性颜色,$ =会把它作为类属性传递(基于聚合物文档)
<div class$="{{color}}"></div>
Run Code Online (Sandbox Code Playgroud)
问题是当我尝试沿现有的一组类添加该类时,例如:
<div class$="avatar {{color}}"></div>
Run Code Online (Sandbox Code Playgroud)
在那种情况下,$ =不起作用.有没有办法完成这个或每次我有条件地添加一个类我必须通过css选择器而不是类包括其余的样式?我知道在这个例子中也许颜色可以简单地进入样式属性,它纯粹是一个例子来说明问题.
请注意,这仅在Polymer 1.0中存在问题.
我对新聚合物发布的一个问题是确定哪些组件正在取代旧组件.对于旧的组件核心列表,我找不到新版本的等价物.有谁知道哪个元素替换核心列表?
我正在尝试在可点击的项目列表上使用涟漪效果,但我面临的问题是,当我将该列表封装到自定义元素中时,涟漪效应遍及整个屏幕.如果我将它放在我的index.html中,但是当我创建一个包含在那里的自定义元素时失败,它会很有效.查看问题的图片:
我一直在阅读类似的问题,答案是使容器相对,这应该已经完成.所以我想知道在使用自定义元素的涟漪效应时是否需要在主机中设置任何特殊属性.
我的示例代码如下.
的index.html
<!doctype html>
<html lang="">
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>List test</title>
<script src="bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="elements/elements.html">
<style>
paper-icon-item {
position: relative;
height: 48px;
}
</style>
</head>
<body unresolved class="fullbleed layout vertical">
<template is="dom-bind" id="app">
<my-list></my-list>
</template>
<script src="scripts/app.js"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我-list.html
<dom-module id="my-list">
<style>
paper-icon-item {
position: relative;
height: 48px;
}
</style>
<template>
<section>
<div class="menu">
<paper-icon-item>
<div class="label" fit>Mark as unread</div>
<paper-ripple></paper-ripple>
</paper-icon-item>
<paper-icon-item>
<div class="label" fit>Mark as important</div>
<paper-ripple></paper-ripple> …
Run Code Online (Sandbox Code Playgroud)