1. 三目运算符切换类名
<view :class="[clsFlag ? 'finish1' : 'finish']" @click="submit" >提交</view>
2.uniapp获取输入框中的内容
<template>
<view>
<text class="name">原密码</text>
<input class="uni-input" :value='oPwd' :type="pwd" focus placeholder="填写原密码" @input="inputChange"/> </view>
<view>
</template>
<script>
export default {
data() {
return {
oPwd:"",
nPwd:"",
}
},
methods: {
inputChange(e) {
this.oPwd = e.detail.value;
}
}
</script>
3. [Vue warn]: Duplicate keys detected: '0'. This may cause an update error. found in解决办法
错误原因:一个template中有两个一样的v-for, key属性冲突导致
<image v-for="(yello,yeIndex) in yelloScore" src="../static/img/light_star.png" class="star-ico" :key="yeIndex"></image> <image v-for="(gray,grIndex) in grayScore" src="../static/img/grey_star.png" class="star-ico" :key="grIndex"></image>
解决方法:
在第二个v-for中, key属性设置一下即可:
<image v-for="(yello,yeIndex) in yelloScore" src="../static/img/light_star.png" class="star-ico" :key="yeIndex"></image> <image v-for="(gray,grIndex) in grayScore" src="../static/img/grey_star.png" class="star-ico" :key="grIndex+'a'"></image>