Skip to content

Commit

Permalink
44th Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Shyam-Chen committed Apr 4, 2021
1 parent 8bcd29e commit b6c87a4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ export default {
</script>
```

:warning: WARNING

Frankly, `state` is static, you cannot use [destructuring assignment](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment) and rename it because it will not be able to update the value.

### Modules

```js
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vuex-bound",
"version": "1.3.1",
"version": "1.3.2",
"description": "Vue two-way binding (v-model) for Vuex state and mutations.",
"main": "dist/vuex-bound.cjs.js",
"module": "dist/vuex-bound.esm.js",
Expand Down
6 changes: 2 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const mapModel = normalizeNamespace((namespace, models) => {
set(value) {
const type = !namespace ? 'updateModel' : `${namespace.split('/').join('/')}/updateModel`;

let originState;
let originState = val;

if (typeof val === 'function') {
const valify = String(val);
Expand All @@ -47,11 +47,9 @@ export const mapModel = normalizeNamespace((namespace, models) => {
valify.indexOf('state.') + 6,
valify.indexOf(';') === -1 ? undefined : valify.indexOf(';'),
);
} else {
originState = val.substring(val.indexOf('.') + 1, val.indexOf(';'));
}

this.$store.commit(type, { label: originState || key, value });
this.$store.commit(type, { label: originState, value });
},
};
});
Expand Down

0 comments on commit b6c87a4

Please sign in to comment.