大家好,我是 Polymer.js 的新手,我正在构建我的 HTML 自定义标签,以便在我的前端工作中重用它们。问题是,当我尝试在 Safari 和 Firefox 中打开我的 index.html 时,我看到的只是没有所有 CSS 的 HTML。在 Chrome 中一切正常。我不明白为什么会这样。 我使用 Polymer 1.0.0,Firefox 和 Safari 都是最新版本。 有什么建议么? 谢谢大家。
这是代码(如您所见,我已经包含了 webcomponents-lite.min.js):
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<title>Polymer Project</title>
<script src="../../bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
<link rel="import" href="app/components/pd-dashboard/dashboard-articles.html" />
<div class="row">
<dashboard-articles> </dashboard-articles>
</div>
<div class="col-sm-2"></div>
</div>
</html>
dashboard-articles.html:
<link rel="import" href="../../../bower_components/polymer/polymer.html">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="import" href="../../components/articles/article-2col/article-2col.html">
<link rel="import" href="../../components/articles/article-1col/article-1col.html">
<link rel="stylesheet" type="css/text" href="../../components/pd-dashboard/dashboard-articles.css" />
<!-- Fonts -->
<link href='https://fonts.googleapis.com/css?family=Dosis:800,600,700' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Nunito:400,700' rel='stylesheet' type='text/css'>
<script src="../../bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
<dom-module id="dashboard-articles">
<template>
<div class="container-fluid">
<div class="row" style="margin: 5px">
</div>
<div class="row">
<hr>
<div class="row">
<div class="col-sm-5">
<article-1col></article-1col>
</div>
<div class="col-sm-7">
</div>
</div>
</div>
</template>
</dom-module>
<script>
Polymer({
is: "dashboard-articles"
});
</script>
最佳答案
问题解决了!
<link>
.css 文件必须在标签 <template>
内在您创建的每个组件中!
关于html - Polymer.js 浏览器兼容性 - 在 Firefox 和 Safari 中看不到 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35069747/