Bootstrap select error: Cannot set property '_menu' of undefined

我的未来我决定 提交于 2019-12-10 21:42:59

问题


I've implemented select box using bootstrap-select in angular 5. I've used latest version of Bootstrap select to make it work angular 5. But it throws below error.

bootstrap-select.js:1904 Uncaught TypeError: Cannot set property '_menu' of undefined

<form>
     <select class="selectpicker" data-live-search="true">
         <option>Mustard</option>
         <option>Ketchup</option>
         <option>Relish</option>
     </select>
</form>

View Plunkr


回答1:


Bootstrap-select v1.13.0-dev is compatible with Boostrap 4. You can find Compatible bootstrap-select files here Boostrap-select

Isue is that i am not loading required jquery and popper.min.js files into project directory. Also use non minified version of bootstrap select from repository code. I've solved this issue by adding above files.




回答2:


https://getbootstrap.com/docs/4.0/components/input-group/#custom-select

Your issue is that you aren't using the select dropdown properly according to Bootstrap 4. You can't upgrade from Bootstrap 3 to Bootstrap 4 without updating your code to use the new methodologies, unfortunately.

<select class="custom-select" data-live-search="true">
      <option>Mustard</option>
      <option>Ketchup</option>
      <option>Relish</option>
  </select>



回答3:


I suspect that the plugin you're using isn't compatible with Bootstrap 4. The documentation and examples all use Bootstrap 3.

https://silviomoreto.github.io/bootstrap-select/




回答4:


It works in bootstrap-select v1.13.11 with bootsrrap v4.3.1 and jQuery v3.4.1.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.11/dist/js/bootstrap-select.min.js"></script>

I found out the problem was with bootstrap.bundle.min.js, please use the latest version instead.



来源:https://stackoverflow.com/questions/49014163/bootstrap-select-error-cannot-set-property-menu-of-undefined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!