Welcome to Qi-U Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
75 views
in Technique[技术] by (71.8m points)

vue.js - Vue, how to get an empty line if I select an option?

There is a dropdown menu with 3 selections. Whatever you select, it will be shown as text on the right. How do I manage that the "Choice1" is not shown at all? It should be just an empty line if you click on "Choice1" while "Choice2" and "Choice3" are still shown. Right now all three options are shown.

      { id: 2, value: "Choice1" },
      { id: 3, value: "Choice2" },
      { id: 4, value: "Choice3" },
    ],

v-model="Example.addressUserModel"
                    :items="addressitems"
                    return-object
                    item-text="value"
                    item-value="id"
                    dense
                    outlined
                    rounded

 v-if="Example.addressUserModel" style="text-align: left; margin-top: 1%">
                        {{Example.addressUserModel.value}} ```
                      

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to answer this question.

1 Answer

0 votes
by (71.8m points)

Replace the interpolation content by

{{Example.addressUserModel.value !== 'Choice1' ? Example.addressUserModel.value : ''}}

Above I have used the ternary operator to check if the selected value is Choice1 . If yes then print '' else print the selected option


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Qi-U Community for programmer and developer-Open, Learning and Share
...