简体   繁体   English

不显示语义UI等级

[英]Semantic UI Ratings not displayed

I cannot make the ratings element displayed. 我无法显示评级元素。 It simply does not appear. 它根本不会出现。 All other things work fine enough 所有其他事情都可以正常工作

I have linked these properly: 我已经正确链接了这些:

And I use it like this: 我这样使用它:

<div class="ui star rating" data-rating="4"></div>

Do I need to do something else to make it work? 我是否需要做其他事情才能使其正常工作?

You need to initialize the rating plugin on the .rating div element in jQuery . 您需要在jQuery.rating div元素上初始化rating插件。

Either add this to your .js file: 将其添加到您的.js文件中:

// This waits for the DOM to load correctly before changing elements
$(document).ready(function(){
    // All your normal JS code goes in here
    $(".rating").rating();
});

Or if you don't have a .js file you can just include this Javascript/jQuery on each page the rating needs displayed. 或者,如果您没有.js文件,则可以在需要显示等级的每个页面上都包含此Javascript/jQuery

<script type="text/javascript">$(document).ready(function(){$(".rating").rating();});</script>

And that will give you the same effect. 这将为您带来相同的效果。

You can also specify different options within the initialization: 您还可以在初始化中指定其他选项:

$('.rating')
  .rating({
    initialRating: 3,
    maxRating: 5
  })
;

You can find a list of options and other examples here: http://semantic-ui.com/modules/rating.html 您可以在此处找到选项列表和其他示例: http : //semantic-ui.com/modules/rating.html

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

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