forked from alibaba/weex
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript-instance.we
More file actions
71 lines (61 loc) · 1.39 KB
/
Copy pathscript-instance.we
File metadata and controls
71 lines (61 loc) · 1.39 KB
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
<!--
* access data
* access computed
* call methods
* get config
* listen and fire component events
* parent component and sub components
* find element
-->
<template>
<div>
<text id="title" class="title">Please check out the source code.</text>
<!-- <subcomponent id="sub"></subcomponent> -->
</div>
</template>
<style>
.title {font-size: 48px;}
</style>
<script>
module.exports = {
data: {
x: 1,
y: 2
},
methods: {
foo: function () {
console.log('foo')
},
test: function () {
// access data
console.log(this.x)
// access computed
console.log(this.z)
// call methods
this.foo()
// get config
console.log(this.$getConfig())
// listen and fire component events
this.$emit('custom')
this.$dispatch('custom')
this.$broadcast('custom')
this.$on('custom', this.foo)
this.$off('custom', this.foo)
// // parent component and sub components
// this.$parent.$emit('custom')
// this.$vm('sub').$emit('custom')
// // find element
// var dom = require('@weex-module/dom')
// dom.scrollToElement(this.$el('title'), {offset: 0})
}
},
computed: {
z: function () {
return this.x + this.y
}
},
ready: function () {
this.test()
}
}
</script>