聚合物自定义元素:重用css和导入(Polymer custom elements: reusing css with import)
问题:
我似乎无法使
<i>
标签呈现Bootstrap图标,它无法识别Bootstrap提供的类:要诊断的要素
tag.html
<link rel="import" href="../bower_components/polymer/polymer.html"> <polymer-element name="polymer-tag" attributes="name"> <template> <link rel="import" href="bootstrap.html"> <style> :host { display: block; } </style> <div> <span class="name">{{ name }}</span> <!-- This classes are not recognized and the icon is not displayed --> <i class="glyphicon glyphicon-plus-sign"></i> </div> </template> <script> Polymer('polymer-tag', {...}); </script> </polymer-element>
我也尝试将导入移到
<polymer-element>
但它也不起作用。
bootstrap.html
包含这个:<link rel="stylesheet" type="text/css" href="../bower_components/bootstrap/dist/css/bootstrap.min.css">
如果不是导入我加载一个指向
bootstrap.css
的简单旧链接然后它工作,但是,如果我也在索引中使用bootstrap.css
,该站点将加载两次bootstrap.css
这是Web组件的限制吗? 这是聚合物的问题吗?
谢谢!
弗兰
Problem:
I cant seem to make the
<i>
tag to render Bootstrap icons, it does not recognize the classes provided by Bootstrap:Elements to Diagnose
tag.html
<link rel="import" href="../bower_components/polymer/polymer.html"> <polymer-element name="polymer-tag" attributes="name"> <template> <link rel="import" href="bootstrap.html"> <style> :host { display: block; } </style> <div> <span class="name">{{ name }}</span> <!-- This classes are not recognized and the icon is not displayed --> <i class="glyphicon glyphicon-plus-sign"></i> </div> </template> <script> Polymer('polymer-tag', {...}); </script> </polymer-element>
I have also tried to move the import outside
<polymer-element>
but it does not work either.
bootstrap.html
contains this:<link rel="stylesheet" type="text/css" href="../bower_components/bootstrap/dist/css/bootstrap.min.css">
If instead of an import I load a simple old link pointing to
bootstrap.css
then it works, but, If I also usebootstrap.css
in the Index, the site will load two timesbootstrap.css
Is this a limitation of Web Components? Is this an issue of Polymer?
Thanks!
Fran
原文:https://stackoverflow.com/questions/22733896
最满意答案
在Decorator模式中 ,您应该从装饰类的接口继承,然后在构造函数中传递实现。 看起来您正在继承具体的
SchedulingService
类。In the Decorator Pattern, you are supposed to inherit from the interface of the decorated class, and then pass the implementation in the constructor. It looks like you are inheriting from the concrete
SchedulingService
class.
相关问答
更多-
对我来说12个参数肯定听起来太多了。 选择减少他们的数字是: 通过将逻辑相关的参数分组到一个对象并传递该对象而不是单个参数来引入参数对象 。 引入一个构建器 (可选地使用方法链接 )。 这不会减少实际的参数列表,但它会使代码更具可读性,并且如果您有几个不同的创建方案并且参数不同,那么它特别有用。 所以,而不是 MyClass someObject = new MyClass(aFoo, aBar, aBlah, aBaz, aBorp, aFlirp, andAGoo); MyClass ...
-
如果你询问Something::new的参数,你会得到Something::new的参数。 如果你想知道Something#initialize的参数,你需要问Something#initialize : Something.instance_method(:initialize).parameters # => [[:req, :a], [:req, :b]] If you ask about the parameters of Something::new, you will get the para ...
-
看起来这可能是一个使用继承的好地方。 你可以有一个FileLogger,DatabaseLogger和EmailLogger,每一个派生自一个基本的ExceptionLogger类,并有一个合适的构造函数。 It seems like this might be a good place to use inheritance instead. You could have a FileLogger, DatabaseLogger, and EmailLogger each of which derives ...
-
Byte Buddy实例化没有构造函数参数的类(Byte Buddy instantiate class without parameters for constructor)[2023-01-13]
定义一个不以某种方式(直接或通过另一个构造函数)调用其超级构造函数的Java构造函数是不合法的,因为它不能用字节代码表示,它不能在Byte Buddy中完成。 你能做的是: 不使用ConstructorStrategy.Default.NO_CONSTRUCTORS完全定义构造ConstructorStrategy.Default.NO_CONSTRUCTORS 。 使用像Objenesis这样的库来实例化一个类。 但请注意,Objenesis正在使用未来Java版本可能不支持的不安全API。 It is ... -
function decodeNames($StrNames){ $this->LstNames = array(); $this->LstNames = json_decode($StrNames, true); if(!$this->LstNames) $this->LstNames = array(); $this->LstNames = array_values($this->LstNames); } function update(){ $this->Ls ...
-
C ++ - 构造函数,其中参数由基类的构造函数使用(C++ - Constructor Where Parameters Are Used By Base Class' Constructor)[2023-04-10]
你需要继承Vehicle: 头文件: class Car: public Vehicle { public: Car(int wheels); }; Cpp文件: Car::Car(int wheels): Vehicle(wheels) { } You need to inherit from Vehicle: Header file: class Car: public Vehicle { public: Car(int wheels); }; Cpp file: Car::Car ... -
您可以使用ReflectionClass轻松实现此目的: function getObject($objectName, $arr = array()) { if (empty($arr)) { // Assumes you correctly pass nothing or array() in the second argument // and that the constructor does accept no arguments retur ...
-
在Decorator模式中 ,您应该从装饰类的接口继承,然后在构造函数中传递实现。 看起来您正在继承具体的SchedulingService类。 In the Decorator Pattern, you are supposed to inherit from the interface of the decorated class, and then pass the implementation in the constructor. It looks like you are inheriting ...
-
类装饰器可以同时接收构造函数和其他参数吗?(Can a class decorator receive both the constructor function and additional arguments?)[2021-07-02]
它以这种方式工作 function test(target, arg1, argN) { return function(clazz) { console.log(target, arg1, clazz) } } @test("hello", "world") class A {} It works this way function test(target, arg1, argN) { return function(clazz) { console.log(targ ... -
从设计的角度来看,我认为你会采用错误的方式。 虽然您可能能够一起破解某些东西来解决构造函数问题,但您正在尝试将Box类用于两个不兼容的用途。 相反,你应该有两个单独的类。 FileHelpers是一个用于描述csv文件的库,以便您可以轻松导入它们。 您应该有一个BoxFileSpec来描述您的文件。 它实际上不是一个合适的C#类 - 它可能有:虚拟字段来表示未使用的列; 许多属性[FieldNullValue] , [FieldQuoted] , [FieldConverter] ; 它最适用于公共字段(F ...