我有一个网页显示一些其中有一些代码的帖子。我正在尝试使用突出显示的js来突出显示代码。但是,我仍然无法在几个小时后开始工作。这是我第一次使用Meteor,因此代码从他们网站上的教程改编而来。整个项目很简单,这里是我的主要js文件:不能让高亮js在流星js工作
Posts = new Mongo.Collection("posts");
if (Meteor.isClient) {
// This code only runs on the client
Template.body.helpers({
posts: function() {
return Posts.find({}, {limit: 15});
}
});
Template.post.rendered = function(){
$('pre code').each(function(i, block) {
hljs.highlightBlock(block);
});
};
}
我使用的HTML文件:
<head>
<title>Posts</title>
</head>
<body>
<div class="container">
<header>
<h1>Posts</h1>
</header>
<ul>
{{#each posts}}
{{> post}}
{{/each}}
</ul>
</div>
</body>
<template name="post">
<h1 class="text">{{title}}</h1>
{{{ content }}}
</template>
我也有从大亮点JS' github上斧头代码风格的css文件项目中的回购。加载页面后,hljs
作为类值添加到代码标记中,但代码标记内的代码保持不变,如下图所示。
任何想法为什么突出js没有改变代码?
如果我的描述不够清楚,我会添加更多信息。
将有助于有一个[meteorpad](http://meteorpad.com/)演示。 – 2015-04-03 05:34:10
@FlorianF。嗨,我去了那里,做了一个演示,它在那里工作。所以我重新构建了我的项目,就像演示项目一样,它也工作得很好。感谢您的建议! – Gnijuohz 2015-04-03 18:43:13