test: add stores no class testing
This commit is contained in:
parent
5c82ea865a
commit
0112509511
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,16 @@
|
|||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
|
||||
<meta charset="UTF-8" />
|
||||
<title>Counter</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script src="b.js"></script>
|
||||
<a href="https://github.com/Tencent/omi" target="_blank" style="position: fixed; right: 0; top: 0; z-index: 3;">
|
||||
<img src="//alloyteam.github.io/github.png" alt="">
|
||||
</a>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -0,0 +1,29 @@
|
|||
import { define, render } from '../../src/omi'
|
||||
import store from './store'
|
||||
|
||||
define('my-app', _ => {
|
||||
const data = _.store.counterStore.data
|
||||
|
||||
const { add, sub } = _.store.counterStore
|
||||
return (
|
||||
<p>
|
||||
Clicked: {data.count} times
|
||||
<button onClick={add}>+</button>
|
||||
<button onClick={sub}>-</button>
|
||||
|
||||
<div>
|
||||
{_.store.msgStore.data.msg}
|
||||
<button onClick={_.store.msgStore.changeMsg}>
|
||||
change storeB's msg
|
||||
</button>
|
||||
</div>
|
||||
</p>
|
||||
)
|
||||
}, {
|
||||
useSelf: {
|
||||
counterStore:['count'],
|
||||
msgStore: ['msg']
|
||||
}
|
||||
})
|
||||
|
||||
render( <my-app /> , 'body', store)
|
|
@ -0,0 +1,15 @@
|
|||
const store = {
|
||||
data:{
|
||||
count: 1
|
||||
}
|
||||
}
|
||||
|
||||
store.add = _ => {
|
||||
store.data.count++
|
||||
}
|
||||
|
||||
store.sub = _ => {
|
||||
store.data.count--
|
||||
}
|
||||
|
||||
export default store
|
|
@ -0,0 +1,12 @@
|
|||
const store = {
|
||||
data:{
|
||||
msg: 'abc'
|
||||
}
|
||||
}
|
||||
|
||||
store.changeMsg = () => {
|
||||
store.data.msg = 'bcd'
|
||||
}
|
||||
|
||||
|
||||
export default store
|
|
@ -0,0 +1,7 @@
|
|||
import counterStore from './store-counter'
|
||||
import msgStore from './store-msg'
|
||||
|
||||
export default{
|
||||
counterStore,
|
||||
msgStore
|
||||
}
|
Loading…
Reference in New Issue