代码:
def answer(s):
# your code herecat
multiplier = 0
salute = 0
for x in range(len(s)):
if s[x] is '<':
multiplier += 1
for x in range(len(s)):
if s[x] is '>':
salute += multiplier
elif s[x] is '<':
multiplier -= 1
ans = salute * 2
return ans
如何获得所选选项的类?
答案 0 :(得分:1)
这应该这样做。
console.clear()
new Vue({
el: "#app",
data:{
order:{
name: null
},
buyers:[{name: "buyer one", id: 1},{name: "buyer two", id: 2}]
},
computed:{
selectedClass(){
const buyer = this.buyers.find(b => b.name === this.order.name)
if (buyer)
return buyer.id
}
}
})
&#13;
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.3.4/vue.js"></script>
<div id="app">
<input type="text" id="buyer_name" list="names" v-model="order.name" class="form-control">
<datalist id="names">
<option v-for="buyer in buyers" :value="buyer.name" :class="buyer.id"></option>
</datalist>
{{selectedClass}}
</div>
&#13;