JavaScript/vue.js/dom属性值

来自康健生活
Kangkk​(留言 | 贡献)2020年7月4日 (六) 03:22的版本 (创建页面,内容为“== e.target.getAttribute == <syntaxhighlight lang="html5"> <li :class="item.value===''?isCountryClass:''" v-for="item in BospitalSearchFilters[0].options" :value="it…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

e.target.getAttribute

<li :class="item.value===''?isCountryClass:''" v-for="item in BospitalSearchFilters[0].options" :value="item.value"
  @click="updateIsCountry($event)">
  {{item.title}}
</li>
updateIsCountry(e) {
  this.isCountry = e.target.getAttribute('value')
  console.log(this)
},

ref

<li :class="item.value===''?isCountryClass:''" v-for="item in BospitalSearchFilters[0].options" :value="item.value"
  @click="updateIsCountry($event)" ref="getValue">
  {{item.title}}
</li>
updateIsCountry(e) {
  this.isCountry = this.$refs.getValue.value
  console.log(this)
},

@click

<li :class="item.value===''?isCountryClass:''" v-for="item in BospitalSearchFilters[0].options" :value="item.value"
  @click="updateIsCountry($event, 'usa')">
  {{item.title}}
</li>
updateIsCountry(e, str) {
  console.log(str)
},