This commit is contained in:
mrjzhang 2019-11-14 21:08:55 +08:00
commit 7801dac815
20 changed files with 39 additions and 51 deletions

View File

@ -29,9 +29,9 @@ HelloWrold.vue:
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<button @click="store.sub">-</button>
<button @click="$store.sub">-</button>
<span>{{state.count}}</span>
<button @click="store.add">+</button>
<button @click="$store.add">+</button>
</div>
</template>
@ -108,9 +108,9 @@ HelloWorld.vue:
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<button @click="store.cs.sub">-</button>
<button @click="$store.cs.sub">-</button>
<span>{{state.cs.count}}</span>
<button @click="store.cs.add">+</button>
<button @click="$store.cs.add">+</button>
</div>
</template>
@ -150,7 +150,7 @@ render(App, '#app', new class {
Bind `getDoubleCount` to template:
```html
<div>double: {{store.getDoubleCount()}}</div>
<div>double: {{$store.getDoubleCount()}}</div>
```
## Differences to Vuex

View File

@ -1,5 +1,5 @@
/**
* omiv v1.0.0 https://tencent.github.io/omi/
* omiv v1.0.1 https://tencent.github.io/omi/
* 1kb store system for Vue apps.
* By dntzhang https://github.com/dntzhang
* Github: https://github.com/Tencent/omi
@ -418,7 +418,7 @@
function applyMixin(Vue) {
var omivComputed = {
state: function state() {
$state: function $state() {
if (isMultiStore) {
var state = {};
Object.keys(this.$store).forEach(function (k) {
@ -427,9 +427,6 @@
return state;
}
return this.$store.data;
},
store: function store() {
return this.$store;
}
};

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
/**
* omiv v1.0.0 https://tencent.github.io/omi/
* omiv v1.0.1 https://tencent.github.io/omi/
* 1kb store system for Vue apps.
* By dntzhang https://github.com/dntzhang
* Github: https://github.com/Tencent/omi
@ -415,7 +415,7 @@ function install(_Vue) {
function applyMixin(Vue) {
var omivComputed = {
state: function state() {
$state: function $state() {
if (isMultiStore) {
var state = {};
Object.keys(this.$store).forEach(function (k) {
@ -424,9 +424,6 @@ function applyMixin(Vue) {
return state;
}
return this.$store.data;
},
store: function store() {
return this.$store;
}
};

File diff suppressed because one or more lines are too long

View File

@ -295,7 +295,7 @@
}
}
var omivComputed = {
state: function() {
$state: function() {
if (isMultiStore) {
var state = {};
Object.keys(this.$store).forEach(function(k) {
@ -304,9 +304,6 @@
return state;
}
return this.$store.data;
},
store: function() {
return this.$store;
}
};
Vue.mixin({

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,11 +1,11 @@
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<button @click="store.cs.sub">-</button>
<span>{{state.cs.count}}</span>
<button @click="store.cs.add">+</button>
<div>double: {{store.cs.getDoubleCount()}}</div>
<span>{{state.ns.name}}</span>
<button @click="$store.cs.sub">-</button>
<span>{{$state.cs.count}}</span>
<button @click="$store.cs.add">+</button>
<div>double: {{$store.cs.getDoubleCount()}}</div>
<span>{{$state.ns.name}}</span>
</div>
</template>

View File

@ -1,10 +1,10 @@
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<button @click="store.sub">-</button>
<span>{{state.count}}</span>
<button @click="store.add">+</button>
<div>double: {{store.getDoubleCount()}}</div>
<button @click="$store.sub">-</button>
<span>{{$state.count}}</span>
<button @click="$store.add">+</button>
<div>double: {{$store.getDoubleCount()}}</div>
</div>
</template>

View File

@ -1,6 +1,6 @@
{
"name": "omiv",
"version": "1.0.0",
"version": "1.0.1",
"description": "1kb store system for Vue apps.",
"main": "dist/omiv.js",
"jsnext:main": "dist/omiv.esm.js",

View File

@ -189,7 +189,7 @@ export function install(_Vue) {
function applyMixin(Vue) {
const omivComputed = {
state() {
$state() {
if (isMultiStore) {
let state = {}
Object.keys(this.$store).forEach(k => {
@ -198,9 +198,6 @@ function applyMixin(Vue) {
return state
}
return this.$store.data
},
store() {
return this.$store
}
}

View File

@ -1,7 +1,7 @@
<template>
<div>
<span class="count">{{ state.count }}</span>
<button @click="store.add">Increment</button>
<span class="count">{{ $state.count }}</span>
<button @click="$store.add">Increment</button>
</div>
</template>

View File

@ -1,6 +1,6 @@
<template>
<div id='app'>
<span class="count">{{ state.count }}</span>
<span class="count">{{ $state.count }}</span>
<button @click="$store.add">Increment</button>
</div>
</template>

View File

@ -1,6 +1,6 @@
<template>
<div id='app'>
<span class="count">{{ state.count }}</span>
<span class="count">{{ $state.count }}</span>
<button @click="$store.add">Increment</button>
</div>
</template>

View File

@ -1,7 +1,7 @@
<template>
<div id="app">
<span class="count">{{ state.count }}</span>
<button id="btn" @click="store.add">Increment</button>
<span class="count">{{ $state.count }}</span>
<button id="btn" @click="$store.add">Increment</button>
</div>
</template>

View File

@ -1,7 +1,7 @@
<template>
<div id="app">
<span class="count">{{ state.cs.count }}</span>
<button id="btn" @click="store.cs.sub">sub</button>
<span class="count">{{ $state.cs.count }}</span>
<button id="btn" @click="$store.cs.sub">sub</button>
</div>
</template>

View File

@ -1,8 +1,8 @@
<template>
<div id="app">
<div>{{state.count}}</div>
<button id="btn" @click="store.add"></button>
<Child :title='state.title' />
<div>{{$state.count}}</div>
<button id="btn" @click="$store.add"></button>
<Child :title='$state.title' />
</div>
</template>

View File

@ -1,7 +1,7 @@
<template>
<div id="app">
<span class="count">{{ state.count }}</span>
<button @click="store.add">Increment</button>
<span class="count">{{ $state.count }}</span>
<button @click="$store.add">Increment</button>
</div>
</template>