选择2 mimetype错误

时间:2017-02-24 18:49:31

标签: javascript css

我正在尝试使用Select2而Chrome拒绝执行该脚本,因为mimetype是text / html。我使用的是4.0.3。这是我的HTML:

<link href="static/js/common/select2/css/select2.min.css" rel="stylesheet" />
<script src="static/js/common/select2/js/select2.js"></script>
<script src="static/js/controllers/common/SelectAgency.js"></script>

<select id="auto"></select>

SelectAgency.js的代码是:

var data = [{ id: 0, text: 'enhancement' }, { id: 1, text: 'bug' }, { id: 2, text: 'duplicate' }, { id: 3, text: 'invalid' }, { id: 4, text: 'wontfix' }];

$("#auto").select2({
 placeholder:'Test'
})

出现选择框,但它不包含任何内容。此消息也会出现在控制台中

select2.min.js:233资源被解释为样式表,但使用MIME类型text / html传输:&#34; http://localhost:8080/foiaonline/action/public/request/static/js/common/select2/js/static/js/controllers/common/select2/css/select2.min.css&#34;。

1 个答案:

答案 0 :(得分:0)

我使用的是旧版本的select2(3.5.1)。在3.5.1中,select2初始化为:

$(panel).select2({
    placeholder:placeholderStr,
    data: items
});

<input id="panel" type="text", class="auto"/></td>