Skip to content

v-if and v-else Causing the button value to be cleared  #4530

Closed
@workwsl

Description

@workwsl

v-if and v-else Causing the button value to be cleared (When the v-if or v-else role of the button, one of which is dynamic value, the value of another button will be emptied)

Vue.js version

Vue:2.1.6

NOTE: This problem does not exist in Vue1.x

Reproduction Link

https://jsfiddle.net/ldneedu/c0xa3Len/5/

Steps to reproduce

Three sets of scenes
Click the Toggle button

<div id="app">
  <p>{{ message }}</p>
  <input type="button" @click="show=!show" value="Toggle">(Switch multiple times to see the results)
  <p>===========scene one=============</p>
 <input v-if="show" type="button" value="button 1">
  <input v-else type="button" :value="btnValue2">
  <p>===========scene two=============</p>
 <input v-if="show" type="button" value="button 1">
 <input v-else type="button" value="button 2">
 <p>===========scene tree=============</p>
 <input v-if="show" type="button" :value="btnValue1">
 <input v-else type="button" :value="btnValue2">
</div>
new Vue({
  el: '#app',
  data: {
    message: 'Hello Vue.js!',
    show: true ,
    btnValue1: 'button 1',
    btnValue2: 'button 2'
  }
})

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions