-
-
Save Fl0pZz/20cb64e309d03cc0c083ea2b6f46053e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template src='./index.html' /> | |
<script src="./index.js" lang="babel"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div @keyup.up="goUp" @keyup.down="goDown" @keyup.left="goLeft" @keyup.right="goRight"> | |
<template v-for="n in size"> | |
<cell v-for="m in size" :value="abc" :isActive="false"></cell> | |
</template> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { mapActions, mapState } from 'vuex' | |
import * as types from 'store/mutation-types' | |
import store from 'store/store' | |
import Cell from './cell/Cell' | |
const FIELD_SIZE = 4 | |
export default { | |
name: 'field', | |
components: { Cell }, | |
data: () => ({ | |
size: FIELD_SIZE | |
}), | |
beforeCreate() { | |
store.commit(types.INIT_STATE, FIELD_SIZE) | |
}, | |
computed: { | |
...mapState([ | |
'field' | |
]) | |
}, | |
methods: { | |
...mapActions([ | |
'goUp', | |
'goDown', | |
'goLeft', | |
'goRight' | |
]) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment