Skip to content

Commit 5efacca

Browse files
committed
Added single-file components example to README
1 parent bc12014 commit 5efacca

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

README.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# vue redux binding higher order component
2-
Vue Redux is tested to work on vue v2 and should be used with vue-jsx or in component template string. For more on vue-jsx https://github.com/vuejs/babel-plugin-transform-vue-jsx
2+
Vue Redux is tested to work on vue v2 and should be used with vue-jsx, component template string or single-file components. For more on vue-jsx https://github.com/vuejs/babel-plugin-transform-vue-jsx
33

44
## Install
55
install through ``npm i redux-vue --save``
@@ -108,3 +108,36 @@ function mapActionToProps(dispatch) {
108108
export default connect(mapStateToProps, mapActionToProps)(App);
109109

110110
```
111+
112+
## If you prefer to use single-file components
113+
```js
114+
// components/Comp.js
115+
<template>
116+
<div>
117+
Hello world!
118+
</div>
119+
</template>
120+
121+
<script>
122+
export default {
123+
name: 'my-comp',
124+
}
125+
</script>
126+
127+
<style >
128+
</style>
129+
```
130+
131+
```js
132+
// components/App.js
133+
import { connect } from 'redux-vue'
134+
135+
import Comp from './Comp'
136+
137+
138+
const mapStateToProps = (state) => ({})
139+
140+
const mapDispatchToProps = (dispatch) => ({})
141+
142+
export default connect(mapStateToProps, mapDispatchToProps)(Comp)
143+
```

0 commit comments

Comments
 (0)