parent
c2bd0ff00e
commit
9ca3a3a47d
3 changed files with 81 additions and 1 deletions
@ -0,0 +1,41 @@ |
||||
<!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-for</title> |
||||
</head> |
||||
<body> |
||||
<div id="app"> |
||||
<h2>v-for遍历数组</h2> |
||||
<ul> |
||||
<li v-for="(item,index) in arr" :title="item"> |
||||
{{ index + 1 }} - {{ item }} |
||||
</li> |
||||
</ul> |
||||
<h2>v-for遍历数组对象</h2> |
||||
<ul> |
||||
<li v-for="(item, index) in arr_obj" :title="item.system"> |
||||
{{ index + 1 }} - {{ item.system }} |
||||
</li> |
||||
</ul> |
||||
</div> |
||||
<script type="text/javascript"> |
||||
const App = { |
||||
data() { |
||||
return { |
||||
arr: ['华为', '苹果', 'Oppo', '小米', 'Vivo'], |
||||
arr_obj: [ |
||||
{system: 'iOS'}, |
||||
{system: 'Android'}, |
||||
{system: '鸿蒙'}, |
||||
] |
||||
} |
||||
} |
||||
} |
||||
Vue.createApp(App).mount("#app") |
||||
</script> |
||||
</body> |
||||
</html> |
@ -0,0 +1,33 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="UTF-8"> |
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
||||
<link rel="stylesheet" href="https://unpkg.com/element-plus/dist/index.css"/> |
||||
<script src="https://unpkg.com/vue@3.2.24/dist/vue.global.js"></script> |
||||
<title>v-model</title> |
||||
</head> |
||||
<body> |
||||
<div id="app"> |
||||
<input type="text" v-model="tips"> |
||||
<h2>{{ tips }}</h2> |
||||
<input type="button" value="修改" @click="change_tips"> |
||||
</div> |
||||
<script type="text/javascript"> |
||||
const App = { |
||||
data() { |
||||
return { |
||||
tips: "初始的文本信息", |
||||
btn_tips: "点击按键后的信息" |
||||
} |
||||
}, |
||||
methods: { |
||||
change_tips: function () { |
||||
this.tips = this.btn_tips |
||||
} |
||||
} |
||||
} |
||||
Vue.createApp(App).mount("#app") |
||||
</script> |
||||
</body> |
||||
</html> |
Loading…
Reference in new issue