Skip to content

Commit c62a9cb

Browse files
committed
add San demo
1 parent 1d25330 commit c62a9cb

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,7 @@ nodejs知识点积累!
3333

3434

3535
==============================
36+
37+
vue-demo and vue knowledge
38+
39+
==============================

San/San-demo.html

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
8+
<title>Document</title>
9+
<style>
10+
#div1 {
11+
width: 750px;
12+
height: 100px;
13+
background: red;
14+
}
15+
16+
#div2 {
17+
width: 562.5pt;
18+
height: 100pt;
19+
background: red;
20+
}
21+
</style>
22+
<script src="https://unpkg.com/san@latest/dist/san.dev.js"></script>
23+
</head>
24+
25+
<body>
26+
<div id="app">
27+
28+
</div>
29+
<script>
30+
var MyApp = san.defineComponent({
31+
template: '<div>'
32+
+'user: <input type="text" placeholder="用户名" value="{= name =}" on-keyup="fnAdd">'
33+
+'<ul>'
34+
+'<li s-for="value,index in arr">'
35+
+'<span>{{value}}</span>'
36+
+'<a href="javascript:;" on-click="fnDelete(index)">删除</a>'
37+
+'</li>'
38+
+'</ul>'
39+
+'</div>',
40+
41+
initData: function () {
42+
return {
43+
name:'',
44+
arr:['apple','banana','orange']
45+
};
46+
},
47+
fnAdd:function(ev){
48+
if(ev.keyCode==13){
49+
var name = this.data.get('name');
50+
this.data.push('arr',name);
51+
this.data.set('name','');
52+
}
53+
},
54+
change:function(){
55+
this.data.set('name','Strive');
56+
},
57+
fnDelete:function(n){
58+
this.data.splice('arr', [n, 1]);
59+
}
60+
});
61+
62+
63+
var myApp = new MyApp();
64+
myApp.attach(document.getElementById('app'));
65+
</script>
66+
</body>
67+
68+
</html>

0 commit comments

Comments
 (0)