【vue】v-if 条件渲染

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <div id="app"> <h2>{{web.show}}</h2> <hr> <p v-show="web.show">这是一段文字,可通过按钮隐藏</p> <p v-if="web.show">www.tao355667.com</p> <button @click="toggle">切换显示状态</button> <p v-if="web.user<1000">新网站</p> <p v-else-if="web.user>=1000 && web.user<10000">良好网站</p> <p v-else-if="web.user>=10000 && web.user<100000">优秀网站</p> <p v-else>非常优秀网站</p> </div> <script type="module"> import { createApp, reactive } from './vue.esm-browser.js' createApp({ setup() { const web = reactive({ show: true, user:1000 }) const toggle = () => { web.show = !web.show; } return { web, toggle } } }).mount("#app") </script> </body> </html>
上一篇:Android Camera预览通道