完成v-model学习

main
RogerWork 1 year ago
parent c2bd0ff00e
commit 9ca3a3a47d
  1. 41
      demo/v-for.html
  2. 33
      demo/v-model.html
  3. 8
      demo/v-on.html

@ -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>

@ -10,12 +10,14 @@
<body>
<div id="app">
<input type="button" value="点击执行" v-on:click="click_action"><br>
<input type="button" value="双击执行" @dblclick="double_action">
<input type="button" value="双击执行" @dblclick="double_action"><br>
<input type="text" :placeholder="msg" v-model="msg" @keyup.enter="alert(msg)">
</div>
<script type="text/javascript">
const App = {
data() {
return {
msg: "请输入后回车提示信息",
count: 0,
}
},
@ -26,6 +28,10 @@
double_action: function () {
alert("当前数值为:" + this.count+', 再次双击将+1')
this.count++
},
alert: function (msg) {
console.log(this.msg)
alert(msg)
}
}
}

Loading…
Cancel
Save