点击加入精英计划可以加入
点击名字可以删除
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Titletitle>
<script src="https://unpkg.com/vue@3/dist/vue.global.js">script>
head>
<body>
<div id="app">
<div>
<h1>精英小组h1>
<h2 v-for="(n,index) in names" @click="del(index)">{{n}}h2>
div>
<div>
<input v-model="name">
<button @click="add">加入精英计划button>
div>
div>
body>
<script>
const {createApp, ref} = Vue
createApp({
setup() {
const names = ref([
"zyd","mxq","wcs"
])
const name = ref("")
const add = () => {
names.value[names.value.length]=name.value;
}
const del = (i) => {
names.value.splice(i,1);
}
return {
names,name,add,del
}
}
}).mount('#app')
script>
html>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59