VUE V-BIND:班级返回无效值
我正在Vue编写一个应用程序,并且我的行为不正确,尤其是我的行:class = require? 'require':''返回字符串'quirect'即使要求的值为false,问题是什么?
<template>
<custom-label label="Название">
<input
class="text_input"
:class="require ? 'require' : ''"
:value="$attrs.value" @input="$emit('input', $event.target.value)"
placeholder="Матрица всея барановичского района"
/>
</custom-label>
</template>
<script>
export default {
name: "InputText",
components: {CustomLabel},
computed: mapState({ state: state => state }),
props: {
require: Boolean
}
};
</script>
以下是devtools
I am writing an application at vue and I am getting incorrect behavior, in particular my line :class=require ? 'require' : '' returns the string 'require' even when the value of require is false, what is the problem?
<template>
<custom-label label="Название">
<input
class="text_input"
:class="require ? 'require' : ''"
:value="$attrs.value" @input="$emit('input', $event.target.value)"
placeholder="Матрица всея барановичского района"
/>
</custom-label>
</template>
<script>
export default {
name: "InputText",
components: {CustomLabel},
computed: mapState({ state: state => state }),
props: {
require: Boolean
}
};
</script>
Below are screenshots from devtools
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
:class =“ {require}”
而不是。Use
:class="{ require }"
instead.在stackoverflow上写了问题之前,我花了3个小时。一旦我发布了这个问题,几分钟后,我意识到我在全球区域中具有要求的功能,例如,
这是一个非常愚蠢的错误,但我希望有人也遇到它将能够在我的答案的帮助下避免它。
I spent 3 hours on this before writing the question on StackOverflow. As soon as I published the question, after a few minutes I realized that I have a require function in the global area, which is needed for example for images
this is a very stupid mistake, but I hope someone who also encounters it will be able to avoid it with the help of my answer.