-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yosef Yuan
committed
Jun 23, 2017
1 parent
0f22564
commit e381eb2
Showing
10 changed files
with
10,080 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!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=edge"> | ||
<script src="./vue.js"></script> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<div id="demo"> | ||
<button @click="show=!show">Toggle</button> | ||
<transition name="v"> | ||
<p v-if="show">hello</p> | ||
</transition> | ||
</div> | ||
<script> | ||
var vm = new Vue({ | ||
el:"#demo", | ||
data:{ | ||
show: true | ||
} | ||
}) | ||
</script> | ||
<style> | ||
.v-enter-active, .v-leave-active{ | ||
transition: opacity .5s | ||
} | ||
.v-enter, .v-leave-to{ | ||
opacity: 0 | ||
} | ||
</style> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<!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=edge"> | ||
<script src="./vue.js"></script> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<div id="demo"> | ||
<example></example> | ||
</div> | ||
<script> | ||
// Vue.component('example',{ | ||
// template:`<span @click.once="updateMessage">{{ msg }}</span>`, | ||
// data () { | ||
// return { | ||
// msg: 'not updated' | ||
// } | ||
// }, | ||
// methods: { | ||
// updateMessage () { | ||
// this.msg = 'updated' | ||
// console.log(this.$el.textContent) | ||
// this.$nextTick(function () { | ||
// console.log(this.$el.textContent) | ||
// }) | ||
// } | ||
// } | ||
// }) | ||
new Vue({ | ||
el: "#demo", | ||
components: { | ||
'example':{ | ||
template:`<span @click.once="updateMessage">{{ msg }}</span>`, | ||
data () { | ||
return { | ||
msg: 'not updated' | ||
} | ||
}, | ||
methods: { | ||
updateMessage () { | ||
this.msg = 'updated' | ||
console.log(this.$el.textContent) | ||
this.$nextTick(function () { | ||
console.log(this.$el.textContent) | ||
}) | ||
} | ||
} | ||
} | ||
} | ||
}) | ||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title></title> | ||
<script type="text/javascript" src="https://cdn.bootcss.com/vue/2.3.4/vue.js"></script> | ||
<!-- <script src="https://unpkg.com/[email protected]/dist/axios.min.js"></script> --> | ||
<!-- <script src="https://unpkg.com/[email protected]/lodash.min.js"></script> --> | ||
</head> | ||
<body> | ||
<script> | ||
Vue.component('child',{ | ||
props:{ | ||
myMsg: { | ||
type:Number | ||
} | ||
}, | ||
template:`<span>{{ myMsg }}</span>` | ||
}) | ||
</script> | ||
<div id="demo"> | ||
<input v-model="parentMsg"> | ||
<child :my-msg="parentMsg"></child> | ||
</div> | ||
<script> | ||
new Vue({ | ||
el:"#demo", | ||
data:{ | ||
parentMsg:100 | ||
} | ||
}) | ||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title></title> | ||
<script type="text/javascript" src="https://cdn.bootcss.com/vue/2.3.4/vue.js"></script> | ||
<!-- <script src="https://unpkg.com/[email protected]/dist/axios.min.js"></script> --> | ||
<!-- <script src="https://unpkg.com/[email protected]/lodash.min.js"></script> --> | ||
</head> | ||
<body> | ||
<div id="demo"> | ||
<p>{{ total }}</p> | ||
<btn-increment v-on:increment="incrementTotal"></btn-increment> | ||
<btn-increment v-on:increment="incrementTotal"></btn-increment> | ||
</div> | ||
<script> | ||
Vue.component('btn-increment',{ | ||
template:`<button v-on:click="incrementFunc">{{ counter }}</button>`, | ||
data () { | ||
return { | ||
counter:0 | ||
} | ||
}, | ||
methods: { | ||
incrementFunc () { | ||
this.counter += 1 | ||
this.$emit('increment') | ||
} | ||
} | ||
}) | ||
new Vue({ | ||
el:"#demo", | ||
data:{ | ||
total:0 | ||
}, | ||
methods:{ | ||
incrementTotal () { | ||
this.total += 1 | ||
} | ||
} | ||
}) | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title></title> | ||
<script type="text/javascript" src="https://cdn.bootcss.com/vue/2.3.4/vue.js"></script> | ||
<!-- <script src="https://unpkg.com/[email protected]/dist/axios.min.js"></script> --> | ||
<!-- <script src="https://unpkg.com/[email protected]/lodash.min.js"></script> --> | ||
</head> | ||
<body> | ||
<div id="demo"> | ||
<currency-input></currency-input> | ||
</div> | ||
<script> | ||
Vue.component('currency-input', { | ||
template:` | ||
<span> | ||
$ | ||
<input | ||
ref="input01" | ||
v-bind:value="value" | ||
v-on:input="updateValue($event.target.value)" | ||
> | ||
</span> | ||
`, | ||
props: ['value'], | ||
methods: { | ||
updateValue: function (value) { | ||
var formattedValue = value | ||
.trim() | ||
.slice(0, value.indexOf('.') + 3) | ||
if (formattedValue !== value) { | ||
this.$refs.input01.value = formattedValue | ||
} | ||
this.$emit('input') | ||
} | ||
} | ||
}) | ||
new Vue({ | ||
el:"#demo" | ||
}) | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title></title> | ||
<script type="text/javascript" src="./vue.js"></script> | ||
<!-- <script src="https://unpkg.com/[email protected]/dist/axios.min.js"></script> --> | ||
<!-- <script src="https://unpkg.com/[email protected]/lodash.min.js"></script> --> | ||
</head> | ||
<body> | ||
<div id="demo"> | ||
<component01></component01> | ||
<component02></component02> | ||
</div> | ||
<div id="demo2"> | ||
<component01></component01> | ||
<component02></component02> | ||
</div> | ||
<script> | ||
var bus = new Vue(); | ||
|
||
Vue.component('component01',{ | ||
template:` | ||
<button>{{ name }}</button> | ||
`, | ||
methods:{ | ||
func (val) { | ||
bus.$on('test',(val)=>{alert(2)}) | ||
} | ||
}, | ||
data(){ | ||
return { | ||
name:'btn1' | ||
} | ||
}, | ||
beforeMount(){//mounted函數亦可 參見vue生命周期图示 | ||
var _this = this; | ||
bus.$on('test', function (val) { | ||
_this.name=val; | ||
}); | ||
} | ||
}); | ||
|
||
Vue.component('component02',{ | ||
template:` | ||
<button v-on:click="funcEmit">btn2</button> | ||
`, | ||
methods:{ | ||
funcEmit () { | ||
bus.$emit('test',"from btn2") | ||
alert(1) | ||
} | ||
} | ||
}); | ||
|
||
new Vue({ | ||
el:"#demo" | ||
}); | ||
new Vue({ | ||
el:"#demo2" | ||
}) | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title></title> | ||
<script type="text/javascript" src="https://cdn.bootcss.com/vue/2.3.4/vue.js"></script> | ||
<!-- <script src="https://unpkg.com/[email protected]/dist/axios.min.js"></script> --> | ||
<!-- <script src="https://unpkg.com/[email protected]/lodash.min.js"></script> --> | ||
</head> | ||
<body> | ||
<script> | ||
Vue.component('my-component', { | ||
template: '<div>A custom component!</div>' | ||
}) | ||
</script> | ||
<div id="example"> | ||
<my-component></my-component> | ||
</div> | ||
<script> | ||
var child1 = { | ||
template:'<div>a child1 component!</div>' | ||
} | ||
var child2 = { | ||
template:'<div>a child2 component!</div>' | ||
} | ||
window.onload =function(){ | ||
|
||
new Vue({ | ||
el: '#example' | ||
}); | ||
new Vue({ | ||
el:"#demo", | ||
components:{ | ||
child1, | ||
child2 | ||
} | ||
}) | ||
} | ||
</script> | ||
<div id="demo"> | ||
<child1></child1> | ||
<child2></child2> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!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=edge"> | ||
<script src="./vue.js"></script> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<div id="demo"> | ||
<button @click="show=!show">Toggle</button> | ||
<transition name="render"> | ||
<p v-show='show'>Hello</p> | ||
</transition> | ||
</div> | ||
<script> | ||
new Vue({ | ||
el:"#demo", | ||
data:{ | ||
show:true | ||
} | ||
}) | ||
</script> | ||
<style> | ||
.render-enter-active, .render-leave{ | ||
opacity: 1; | ||
} | ||
.render-enter, .render-leave-active{ | ||
transform:translateX(10px); | ||
opacity: 0; | ||
} | ||
.render-enter-active, .render-leave-active{ | ||
transition: all .5s ease; | ||
} | ||
</style> | ||
</body> | ||
</html> |
Oops, something went wrong.