IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VueJS Discussion :

Composant select déroulable avec vue js depuis un exemple en js


Sujet :

VueJS

  1. #1
    Membre à l'essai Avatar de Sinbad93
    Homme Profil pro
    Apprenti Dev
    Inscrit en
    octobre 2020
    Messages
    23
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 30
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Apprenti Dev

    Informations forums :
    Inscription : octobre 2020
    Messages : 23
    Points : 20
    Points
    20
    Par défaut Composant select déroulable avec vue js depuis un exemple en js
    Bonjour les Vue.js,
    J'essaie de rendre un select 'scrollable', j'ai trouvé un exemple en js mais je n'arrive pas à le transposer en vue js, quelqu'un voit comment faire svp?
    Voici l'exemple en js, ci dessous le code (lien que vous trouverez ici lien)
    le code en js :

    Code HTML : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    <select onfocus='this.size=3;' onblur='this.size=1;' onchange='this.size=1; this.blur();'>
            <option>1</option>
            <option>2</option>
            <option>3</option>
            <option>4</option>
            <option>5</option>
            <option>6</option>
            <option>7</option>
            <option>8</option>
            <option>9</option>
            <option>10</option>
            <option>11</option>
            <option>12</option>
            <option>13</option>
            <option>14</option>
            <option>15</option>
            <option>16</option>
            <option>17</option>
            <option>18</option>
            <option>19</option>
            <option>20</option>
        </select>

  2. #2
    Membre à l'essai Avatar de Sinbad93
    Homme Profil pro
    Apprenti Dev
    Inscrit en
    octobre 2020
    Messages
    23
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 30
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Apprenti Dev

    Informations forums :
    Inscription : octobre 2020
    Messages : 23
    Points : 20
    Points
    20
    Par défaut solution
    Voici la solution qui m'a finalement été apportée ailleurs, a tester pour les intéressés:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
     
    <script>
    import HelloWorld from "./components/HelloWorld.vue";
    import { defineComponent } from "vue";
     
    export default defineComponent({
      components: {
        HelloWorld,
      },
      data() {
        return {
          size: 1,
        };
      },
      methods: {
        onFocus: function () {
          this.size = 3;
        },
        onBlur: function () {
          this.size = 1;
        },
        onChange: function (event) {
          this.size = 1;
          event.target.blur();
        },
      },
    });
    </script>
     
    <template>
      <img alt="Vue logo" src="./assets/logo.png" />
      <HelloWorld msg="Hello Vue 3 + Vite" />
      <p>Version HTML</p>
      <select
        class="html-version"
        onfocus="this.size=3;"
        onblur="this.size=1;"
        onchange="this.size=1; this.blur();"
      >
        <option>1</option>
        <option>2</option>
        <option>3</option>
        <option>4</option>
        <option>5</option>
        <option>6</option>
        <option>7</option>
        <option>8</option>
        <option>9</option>
        <option>10</option>
        <option>11</option>
        <option>12</option>
        <option>13</option>
        <option>14</option>
        <option>15</option>
        <option>16</option>
        <option>17</option>
        <option>18</option>
        <option>19</option>
        <option>20</option>
      </select>
      <p>Version Vue</p>
      <select
        class="vue-size-version"
        :size="size"
        @focus="onFocus"
        @blur="onBlur"
        @change="onChange"
      >
        <option>1</option>
        <option>2</option>
        <option>3</option>
        <option>4</option>
        <option>5</option>
        <option>6</option>
        <option>7</option>
        <option>8</option>
        <option>9</option>
        <option>10</option>
        <option>11</option>
        <option>12</option>
        <option>13</option>
        <option>14</option>
        <option>15</option>
        <option>16</option>
        <option>17</option>
        <option>18</option>
        <option>19</option>
        <option>20</option>
      </select>
    </template>
     
    <style>
    #app {
      font-family: Avenir, Helvetica, Arial, sans-serif;
      -webkit-font-smoothing: antialiased;
      -moz-osx-font-smoothing: grayscale;
      text-align: center;
      color: #2c3e50;
      margin-top: 60px;
    }
    </style>

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 6
    Dernier message: 16/03/2022, 16h45
  2. [INSERT][SELECT] insert avec un select imbriqué
    Par narmataru dans le forum SQL
    Réponses: 11
    Dernier message: 06/03/2013, 03h04
  3. Select dans une vue avec hibernate
    Par Sniper37 dans le forum Hibernate
    Réponses: 1
    Dernier message: 04/03/2009, 16h25
  4. [struts][JSP][select] problème avec le select
    Par redge_touch dans le forum Struts 1
    Réponses: 4
    Dernier message: 14/01/2004, 10h05
  5. [composant][MX_2004_pro] prob avec scrollpane
    Par scorpiwolf dans le forum Flash
    Réponses: 6
    Dernier message: 12/01/2004, 20h18

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo