Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
demo-vue-vuex
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Hooke
2016-10-29 20:32:05 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
bdbb14fa359ffc80a738499639459e8256d1274f
bdbb14fa
1 parent
f5677ae4
render 组件
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
35 deletions
src/App.vue
src/components/child.vue
src/main.js
src/App.vue
View file @
bdbb14f
<template>
<div id="app">
<div id="app">
<counter></counter>
<p>
<button @click="increment">+</button>
<button @click="decrement">-</button>
<button @click="increment">+</button>
<button @click="decrement">-</button>
</p>
</div>
<child :level="1">Hello world!</child>
<child :level="3">Hello world!</child>
</div>
</template>
<script>
import counter from './components/counter.vue'
import {store} from './main.js'
import child from './components/child.vue'
import {
store
} from './main.js'
export default {
name: 'app',
data
() {
return {
name: 'app',
data
() {
return {
}
},
computed: {
count () {
return store.state.count
}
},
methods: {
increment () {
store.commit('increment')
}
},
computed: {
count() {
return store.state.count
}
},
methods: {
increment() {
store.commit('increment')
},
decrement() {
store.commit('decrement')
}
},
decrement ()
{
store.commit('decrement')
components:
{
counter,child
}
},
components: {
counter
}
}
</script>
...
...
src/components/child.vue
0 → 100644
View file @
bdbb14f
<script>
export default {
data() {
return {
}
},
computed: {
},
mounted() {
},
methods: {},
components: {},
render: function(createElement) {
return createElement(
'h' + this.level,
this.$slots.default
)
},
props: {
level: {
type: Number,
required: true
}
}
}
</script>
<style lang="css">
</style>
src/main.js
View file @
bdbb14f
...
...
@@ -5,19 +5,21 @@ import App from './App.vue'
Vue
.
use
(
Vuex
)
const
store
=
new
Vuex
.
Store
({
state
:
{
count
:
0
},
mutations
:
{
increment
:
state
=>
state
.
count
++
,
decrement
:
state
=>
state
.
count
--
}
state
:
{
count
:
0
},
mutations
:
{
increment
:
state
=>
state
.
count
++
,
decrement
:
state
=>
state
.
count
--
}
})
new
Vue
({
el
:
'#app'
,
store
,
render
:
h
=>
h
(
App
)
el
:
'#app'
,
store
,
render
:
h
=>
h
(
App
)
})
export
{
store
}
export
{
store
}
...
...
Please
register
or
login
to post a comment