You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
888 B
31 lines
888 B
<!DOCTYPE html> |
|
<html lang="en"> |
|
<head> |
|
<meta charset="UTF-8"> |
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|
<meta http-equiv="X-UA-Compatible" content="ie=edfe"> |
|
<script src="https://unpkg.com/vue@3.3.4/dist/vue.global.js"></script> |
|
<title>v-if</title> |
|
</head> |
|
<body> |
|
<div id="app"> |
|
<img src="https://v2.cn.vuejs.org/images/logo.svg" alt="" v-show="true"> |
|
<img src="https://v2.cn.vuejs.org/images/logo.svg" alt="" v-show="false"> |
|
<h2 v-show="isShow">对象形式</h2> |
|
<h2 v-if="age<18">未成年</h2> |
|
<h2 v-else-if="age<35">还凑合能干</h2> |
|
<h2 v-else>没人要了</h2> |
|
</div> |
|
<script type="text/javascript"> |
|
const App = { |
|
data() { |
|
return { |
|
isShow: false, |
|
age: 33, |
|
} |
|
} |
|
} |
|
Vue.createApp(App).mount("#app") |
|
</script> |
|
</body> |
|
</html>
|
|
|