Vue. js uses v-if v-else to find no solution, vue. jsv-if

Source: Internet
Author: User

Vue. js uses v-if v-else to find no solution, vue. jsv-if

No execution was found using v-if v-else.

I have been studying Vue recently. Because I have just started learning Vue, I will always encounter such a problem. One of the mistakes I want to make today is that when I read the official documentation of Vue, it is found that when the v-if and v-else commands are used, the corresponding content appears

Initial code:

<Div v-if = "Math. random> 0.5 ">" Math. random> 0.5 "</div> <div v-else>" Math. random <= 0.5 "</div>

Result:

"Math. random> 0.5" "Math. random <= 0.5"

Later I found that I forgot to create an instance. Every Vue application should create an instance. Therefore, the modified Code is as follows:

<Div id = "test"> <div v-if = "Math. random> 0.5 ">" Math. random> 0.5 "</div> <div v-else>" Math. random <= 0.5 "</div> <script type =" text/javascript "> new Vue ({el:" # test "}) </script>

Thank you for reading this article. I hope it will help you. Thank you for your support for this site!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.