Skip to content

Update for Vue 2.0 #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 31, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Note:

2. Computed properties can be declared as class property accessors.

3. `data`, `el` and all Vue lifecycle hooks can be directly declared as class member methods as well, but you cannot invoke them on the instance itself. When declaring custom methods, you should avoid these reserved names.
3. `data`, `render` and all Vue lifecycle hooks can be directly declared as class member methods as well, but you cannot invoke them on the instance itself. When declaring custom methods, you should avoid these reserved names.

4. For all other options, pass them to the decorator function.

Expand Down Expand Up @@ -42,7 +42,7 @@ class App {
}

// lifecycle hook
ready () {
mounted () {
this.greet()
}

Expand Down
2 changes: 1 addition & 1 deletion example/example.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title></title>
</head>
<body>
<div id="el" prop-message="Hello!"></div>
<div id="el"></div>
<script src="build.js"></script>
</body>
</html>
35 changes: 23 additions & 12 deletions example/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,7 @@ import Component from '../'
@Component({
props: {
propMessage: String
},
template: `
<div>
<input v-model="msg">
<p>prop: {{propMessage}}</p>
<p>msg: {{msg}}</p>
<p>computed msg: {{computedMsg}}</p>
<button @click="greet">Greet</button>
</div>
`
}
})
class App {
// return initial data
Expand All @@ -23,7 +14,7 @@ class App {
}

// lifecycle hook
ready () {
mounted () {
this.greet()
}

Expand All @@ -36,9 +27,29 @@ class App {
greet () {
alert('greeting: ' + this.msg)
}

render (h) {
return (
h('div', [
h('input', {
domProps: { value: this.msg },
on: {
input: (event) => {
this.msg = event.target.value
}
}
}),
h('p', ['prop: ', this.propMessage]),
h('p', ['msg: ', this.msg]),
h('p', ['computed msg: ', this.computedMsg]),
h('button', { on: { click: this.greet }}, ['Greet'])
])
)
}
}

// mount
new App({
el: '#el'
el: '#el',
render: h => h(App, { props: { propMessage: 'Hello!' }})
})
16 changes: 8 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ var Vue = require('vue')

var internalHooks = [
'data',
'el',
'init',
'beforeCreate',
'created',
'ready',
'beforeCompile',
'compiled',
'beforeMount',
'mounted',
'beforeDestroy',
'destroyed',
'attached',
'detached',
'activate'
'beforeUpdate',
'updated',
'activated',
'deactivated',
'render'
]

function componentFactory (Component, options) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"chai": "^3.5.0",
"mocha": "^2.4.5",
"node-libs-browser": "^1.0.0",
"vue": "^1.0.16",
"vue": "^2.0.0-rc.4",
"webpack": "^1.12.12"
}
}