Skip to content

Commit b10b136

Browse files
author
zanjs
committed
🐶 init
0 parents  commit b10b136

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+33590
-0
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
dist
2+
node_modules
3+
bower_components
4+
.idea
5+
*.swp
6+
.DS_Store
7+
.DS_Store?

README.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
##vue+gulp+webpack 单页面组件开发
2+
######网络问题 开发保留了node_modules文件夹
3+
-----------------------------------
4+
5+
##node环境
6+
7+
browser-sync
8+
webpack
9+
gulp
10+
11+
12+
##开发命令
13+
14+
gulp
15+
16+
3
17+
##源码分析命令
18+
19+
gulp vue

develop/components/header/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
require('./style.styl')
2+
3+
module.exports = {
4+
template: require('./template.html'),
5+
props: ['msg']
6+
}

develop/components/header/style.styl

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
app-header
2+
color #bada55
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1>{{msg}}</h1>

develop/components/pane/index.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require('./style.styl')
2+
3+
module.exports = {
4+
template: require('./template.html'),
5+
replace: true,
6+
props: ['side', 'name']
7+
}

develop/components/pane/style.styl

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.pane
2+
display inline-block
3+
width 300px
4+
height 300px
5+
box-sizing border-box
6+
padding 15px 30px
7+
border 2px solid #f3f3f3
8+
margin 10px

develop/components/pane/template.html

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<div class="pane">
2+
<p>This is the {{side}} pane!</p>
3+
<p>{{name}}</p>
4+
</div>

develop/main.js

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
// With proper loader configuration you can load,
2+
// pre-process and insert css directly with require().
3+
// See webpack.config.js for details.
4+
require('./main.styl')
5+
6+
var Vue = require('vue');
7+
8+
var a = Vue.component('user-profile', {
9+
template: '<li {{view}}>{{user.name}} {{user.email}} {{user.msg}} {{parents}}</li>',
10+
props: ['parents'],
11+
data: function() {
12+
return {
13+
msg: '我的测试'
14+
}
15+
},
16+
17+
computed: {
18+
msg: {
19+
set: function() {
20+
alert(2)
21+
},
22+
get: function() {
23+
alert(1)
24+
}
25+
}
26+
},
27+
28+
compiled: function() {
29+
this.$log(this)
30+
},
31+
created: function() {
32+
this.$dispatch('child-created', this)
33+
}
34+
})
35+
36+
37+
var app = new Vue({
38+
el: '#app',
39+
data: {
40+
view: 'page-a',
41+
users: [{
42+
name: 'Chuck Norris',
43+
44+
}, {
45+
name: 'Bruce Lee',
46+
47+
}, {
48+
name: 'Bruce Lee',
49+
50+
}, {
51+
name: '111e',
52+
email: '12312312312'
53+
}],
54+
parents: 'Aaron'
55+
},
56+
57+
created: function() {
58+
this.$on('child-created', function(child) {
59+
// console.log(child)
60+
})
61+
},
62+
63+
components: {
64+
// define the main pages as async components.
65+
'page-a': function(resolve) {
66+
require(['./views/a'], resolve)
67+
},
68+
'page-b': function(resolve) {
69+
require(['./views/b'], resolve)
70+
}
71+
}
72+
})
73+
74+
75+
console.log(app)
76+
77+
78+
/**
79+
* Some really crude routing logic here, just for
80+
* demonstration purposes. The key thing to note here is
81+
* that we are simply changing the view of the root app -
82+
* Vue's async components and Webpack's code splitting will
83+
* automatically handle all the lazy loading for us.
84+
*/
85+
86+
function route() {
87+
app.view = window.location.hash.slice(1) || 'page-a'
88+
}
89+
90+
window.addEventListener('hashchange', route)
91+
window.addEventListener('load', route)

develop/main.styl

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
html, body
2+
font-family Helvetica, Arial, sans-serif
3+
4+

develop/views/a/a.styl

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.view
2+
transition all .4s ease
3+
position absolute
4+
&.expand-enter
5+
opacity 0
6+
-webkit-transform translate3d(100px, 0, 0)
7+
transform translate3d(100px, 0, 0)
8+
&.v-leave
9+
opacity 0
10+
-webkit-transform translate3d(-100px, 0, 0)
11+
transform translate3d(-100px, 0, 0)

develop/views/a/index.js

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
require('./a.styl')
2+
3+
var Vue = require('vue');
4+
5+
Vue.transition('expand', {
6+
7+
beforeEnter: function(el) {
8+
console.log('beforeEnter')
9+
// el.textContent = 'beforeEnter'
10+
},
11+
enter: function(el) {
12+
console.log('enter')
13+
// el.textContent = 'enter'
14+
},
15+
afterEnter: function(el) {
16+
console.log('afterEnter')
17+
// el.textContent = 'afterEnter'
18+
},
19+
enterCancelled: function(el) {
20+
console.log('enterCancelled')
21+
// handle cancellation
22+
},
23+
24+
beforeLeave: function(el) {
25+
console.log(222)
26+
// el.textContent = 'beforeLeave'
27+
},
28+
leave: function(el) {
29+
// el.textContent = 'leave'
30+
},
31+
afterLeave: function(el) {
32+
// el.textContent = 'afterLeave'
33+
},
34+
leaveCancelled: function(el) {
35+
// handle cancellation
36+
}
37+
})
38+
39+
40+
41+
module.exports = {
42+
template: require('./template.html'),
43+
replace: true,
44+
data: function() {
45+
return {
46+
msg: 'This is page A.',
47+
leftName: 'Bruce Lee',
48+
rightName: 'Chuck Norris'
49+
}
50+
},
51+
compiled: function() {
52+
this.$emit('data-loaded')
53+
},
54+
components: {
55+
'app-header': require('../../components/header'),
56+
'app-pane': require('../../components/pane')
57+
}
58+
}

develop/views/a/template.html

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<div class="view" v-transition="expand">
2+
<app-header msg="{{msg}}"></app-header>
3+
<app-pane side="left" name="{{leftName}}"></app-pane>
4+
<app-pane side="right" name="{{rightName}}"></app-pane>
5+
</div>

develop/views/b/index.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
template: require('./template.html'),
3+
replace: true,
4+
compiled: function() {
5+
this.$emit('data-loaded')
6+
}
7+
}

develop/views/b/template.html

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<div class="view" v-transition>
2+
<h1>This is page B.</h1>
3+
<p>I'm... a bit less complicated.</p>
4+
</div>

0 commit comments

Comments
 (0)