-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlx.html
110 lines (108 loc) · 2.45 KB
/
lx.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="vue.js"></script>
</head>
<style>
*{
margin:0;
padding: 0;
list-style: none;
}
html , body{
width:100%;
height:100%;
overflow: hidden;
background: #effaff;
}
header{
width: 100%;
height:80px;
background: #0b0b0b;
}
section{
width: 100%;
height:calc(100% - 80px);
position: relative;
}
.list{
width:230px;
height:128px;
border-radius: 5px;
position: absolute;
padding: 10px;
}
</style>
<body>
<div id="app">
<header>
</header>
<section>
{{name}}
<notes v-for="(item,index) in notes" :key="index" :msg="item" :aa="name" v-on:schange="update"></notes>
</section>
</div>
<script>
Vue.component('notes',{
props:['msg','aa'],
data:function(){
return {
smsg: Object.assign({},this.msg)
}
},
template:`
<div class='list' :style="{left:smsg.x+'px',top:smsg.y+'px',border:'1px solid '+smsg.color}">
<h1> {{smsg.type}} <span>X</span></h1>
<textarea v-model="smsg.content"></textarea>
</div>
`,
methods:{
change(){
// this.name +='hello';
// this.$emit('pchange',this.name);
}
},
watch:{
'smsg':{
handler:function(v,oldv){
this.$emit('schange',this.smsg);
},
deep:true
}
}
});
let app = new Vue({
el:'#app',
data:{
notes:[],
name:'zhangsan'
},
methods: {
update(v) {
let index = 0;
this.notes.forEach((element,i)=>{
if(element.id == v.id){
index = i;
}
})
this.notes.splice(index,1,v);
}
},
watch:{
'notes':{
handler:function(){
localStorage.notes = JSON.stringify(this.notes );
},
deep:true
}
},
mounted(){
this.notes = JSON.parse(localStorage.notes);
}
})
// app.$watch('notes')
</script>
</body>
</html>