在 bootstrap-vue select 选项中插入图像

Inserting images inside the bootstrap-vue select options

有没有办法在Bootstrap-vue select下拉列表中插入图片,如下图所示?

我不认为你可以使用 bootstrap-vue 实现这一点,因为它使用原生 select 输入字段,但你可以使用 vue-select 并且非常简单: https://sagalbot.github.io/vue-select/docs/Advanced/Templating.html

是的,可以通过用 <b-dropdown-item> 包装一个 img 标签来做到这一点,例如:

      <b-dropdown-item> <img scr="..."  /></b-dropdown-item>

new Vue({
  el: '#app'

});
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap/dist/css/bootstrap.min.css" />
  <link rel="stylesheet" href="style.css">
  <link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap/dist/css/bootstrap.min.css" />
  <link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.css" />

  <!-- Add this after vue.js -->
  <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.js"></script>
  <script src="//unpkg.com/babel-polyfill@latest/dist/polyfill.min.js"></script>
  <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
  <script src="//unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.js"></script>

</head>

<body>

  <div id="app">

    <b-dropdown id="ddown1" text="Dropdown Button" class="m-md-2">
      <b-dropdown-item>
        <img src="https://cdn4.buysellads.net/uu/1/21673/1538677471-digitalocean-260x200-light_1_.png" alt="" border="0" height="50" width="65" style="max-width: 130px;">
      </b-dropdown-item>
      <b-dropdown-item> <img src="https://cdn4.buysellads.net/uu/1/21673/1538677471-digitalocean-260x200-light_1_.png" alt="" border="0" height="50" width="65" style="max-width: 130px;"></b-dropdown-item>
      <b-dropdown-item> <img src="https://cdn4.buysellads.net/uu/1/21673/1538677471-digitalocean-260x200-light_1_.png" alt="" border="0" height="50" width="65" style="max-width: 130px;"></b-dropdown-item>
      <b-dropdown-divider></b-dropdown-divider>
      <b-dropdown-item>Something else here...</b-dropdown-item>
      <b-dropdown-item disabled>Disabled action</b-dropdown-item>
    </b-dropdown>
  </div>


</body>

</html>