本来想做表单验证,错误的input想改为红色的颜色
<input class="uni-input" type="number" v-model="name"
placeholder="请输入名称"
name="name" :class="{'error':errClass}" />
<button @click="onClick">按钮<button>
<script>
export default {
data() {
return {
errClass:false,
name:""
}
},
methods: {
onClick() {
this.errClass= true
},
}
</script>
<style>
.error{ color:red }
<style>
5***@qq.com (作者)
修改了 还是不行!
2019-01-14 17:00
7***@qq.com
:class = "errClass ? 'error' : '' " 刚刚写错了,这样呢
2019-01-14 17:02