多个v-if后面跟一个v-else,第一个v-if生效之后 v-else还是生效了,不知道这个是其语言的特性还是存在的问题? #10484
Unanswered
sun-feel
asked this question in
Help/Questions
Replies: 2 comments
-
v-if 每个条件都是单独判断的,是并行的关系,如果想串行应该用 v-if v-else-if 串起来 |
Beta Was this translation helpful? Give feedback.
0 replies
-
原来如此,谢谢大佬,非常感激,明白了
…------------------ 原始邮件 ------------------
发件人: ***@***.***>;
发送时间: 2024年3月9日(星期六) 上午10:57
收件人: ***@***.***>;
抄送: ***@***.***>; ***@***.***>;
主题: Re: [vuejs/core] 多个v-if后面跟一个v-else,第一个v-if生效之后 v-else还是生效了,不知道这个是其语言的特性还是存在的问题? (Discussion #10484)
v-if 每个条件都是单独判断的,是并行的关系,如果想串行应该用 v-if v-else-if 串起来
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
大佬,今天写代买时遇到一个奇怪的问题,正如标题所说的,我的代码大概如下(伪代码):
`
div1 v-if="state === '1'"
div2 v-if="state === '2'"
div3 v-if="state === '3'"
div4 v-if="state === '4'"
div5 v-else
state = '1'
`
我觉得这段代码应该被渲染为
div1
,但我遇到的结果却是div1
和div5
当我将
div5
放到div1
的后面时结果得到了我想要的渲染结果——只渲染了div1
,修改结果代码(伪代码)如下:`
div1 v-if="state === '1'"
div5 v-else />
div2 v-if="state === '2'"
div3 v-if="state === '3'"
div4 v-if="state === '4'"
state = '1'
`
Beta Was this translation helpful? Give feedback.
All reactions