简体   繁体   English

MeteorJS外部文件:css和js

[英]MeteorJS external files: css and js

I am trying to add this bootstrap theme to my project http://ironsummitmedia.github.io/startbootstrap-creative/ this theme have 4 js files beside jquery and bootstrap. 我正在尝试将此Bootstrap主题添加到我的项目中http://ironsummitmedia.github.io/startbootstrap-creative/这个主题在jquery和bootstrap旁边有4个js文件。

I added jquery and bootstrap to my project, This 4 files are in the compatibility folder, as Metereor doc said, but It did not work. 我将jquery和bootstrap添加到了我的项目中,正如Metereor doc所说,这4个文件位于兼容性文件夹中,但是没有用。 The navbar effect when scroll down the page is not working and I sometimes(If I leave the .js files name untouched) got an error about fitText.js file. 向下滚动页面时的导航栏效果不起作用,有时(如果我保持.js文件名不变),我会遇到关于fitText.js文件的错误。

PD1: Compatibility folder loads the .js files in alphabetical order. PD1:兼容性文件夹按字母顺序加载.js文件。

PD2: I tried a lot of suggestions that I found, here in stack and meteor forums but nothing happen. PD2:我在堆栈和流星论坛中尝试了很多发现的建议,但没有任何反应。

I put css and less files in client/lib/stylesheet and they seens to be ok. 我把css和更少的文件放在client / lib / stylesheet中,它们看起来还可以。

What can I do to make this theme to work in meteor.? 如何使该主题在流星中起作用?

Thanks. 谢谢。

NOTE: JS Files 注意:JS文件

  • 1.jquery.easing.min.js 1.jquery.easing.min.js
  • 2.jquery.fittext.js 2.jquery.fittext.js
  • 3.wow.min.js 3.wow.min.js

  • 4.creative.js 4.creative.js

I place them with creative theme load order 我按创意主题加载顺序放置它们

You have two primary options: 您有两个主要选择:

  1. Create a meteor package . 创建一个流星包 If you do a nice job of this then you might wish to share it with the community via atmosphere.js and github so that everyone else can take advantage of your work. 如果您的工作做得不错,那么您可能希望通过amosphere.js和github与社区共享它,以便其他人都可以利用您的工作。
  2. Put your theme's .js files under /public then create a file somewhere in your /client directory tree called head.html that doesn't include any <template name="foo"> directives. 将主题的.js文件放在/ public下,然后在/ client目录树中的某个位置创建一个名为head.html的文件,该文件不包含任何<template name="foo">指令。 Instead just include the directives you want in the <head> section of all your pages bracketed by <head> and </head> . 相反,只需在所有页面的<head>部分中包含所需的指令,并用<head></head>括起来。 Refer to your .js files from that section of html. 从html的该部分引用您的.js文件。

The <head> section is also useful for establishing your google SEO codes and also your google webmaster tools verification code. <head>部分对于建立您的google SEO代码以及google网站管理员工具验证代码也很有用。

I found a solution that works perfect. 我找到了一个完美的解决方案。 I hope it could help other people, I use jquery and .rendered to load the scrips after the page is fully rendered and all the effects I wanted to use where available 我希望它能对其他人有所帮助,我会在页面完全渲染后使用jquery和.rendered加载脚本,并在可用的情况下使用所有想要的效果

Template.layout.rendered = function() {

  $('head').append('<script type="text/javascript" src="/javascript/jquery.easing.min.js"></script>');
  $('head').append('<script type="text/javascript" src="/javascript/jquery.fittext.js"></script>');
  $('head').append('<script type="text/javascript" src="/javascript/wow.min.js"></script>');
  $('head').append('<script type="text/javascript" src="/javascript/creative.js"></script>');

}

There is no need to provide the reference of stylesheets in the meteor. 无需在流星中提供样式表的引用。 Just put your CSS file in client/stylesheets folder. 只需将CSS文件放在client / stylesheets文件夹中即可。 Meteor will automatically apply these CSS rules. 流星将自动应用这些CSS规则。

And the same goes with JS as well. JS也是如此。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM