File tree Expand file tree Collapse file tree 14 files changed +11807
-0
lines changed Expand file tree Collapse file tree 14 files changed +11807
-0
lines changed Original file line number Diff line number Diff line change 1+ .DS_Store
2+ node_modules
3+ /dist
4+
5+ # local env files
6+ .env.local
7+ .env. * .local
8+
9+ # Log files
10+ npm-debug.log *
11+ yarn-debug.log *
12+ yarn-error.log *
13+ pnpm-debug.log *
14+
15+ # Editor directories and files
16+ .idea
17+ .vscode
18+ * .suo
19+ * .ntvs *
20+ * .njsproj
21+ * .sln
22+ * .sw ?
Original file line number Diff line number Diff line change 1+ module . exports = {
2+ presets : [
3+ '@vue/cli-plugin-babel/preset'
4+ ]
5+ }
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " vue-noob-vuex" ,
3+ "version" : " 0.1.0" ,
4+ "private" : true ,
5+ "scripts" : {
6+ "serve" : " vue-cli-service serve" ,
7+ "build" : " vue-cli-service build" ,
8+ "lint" : " vue-cli-service lint"
9+ },
10+ "dependencies" : {
11+ "axios" : " ^0.19.2" ,
12+ "core-js" : " ^3.6.5" ,
13+ "vue" : " ^2.6.11" ,
14+ "vuex" : " ^3.5.1"
15+ },
16+ "devDependencies" : {
17+ "@vue/cli-plugin-babel" : " ~4.4.0" ,
18+ "@vue/cli-plugin-eslint" : " ~4.4.0" ,
19+ "@vue/cli-service" : " ~4.4.0" ,
20+ "babel-eslint" : " ^10.1.0" ,
21+ "eslint" : " ^6.7.2" ,
22+ "eslint-plugin-vue" : " ^6.2.2" ,
23+ "vue-template-compiler" : " ^2.6.11"
24+ },
25+ "eslintConfig" : {
26+ "root" : true ,
27+ "env" : {
28+ "node" : true
29+ },
30+ "extends" : [
31+ " plugin:vue/essential" ,
32+ " eslint:recommended"
33+ ],
34+ "parserOptions" : {
35+ "parser" : " babel-eslint"
36+ },
37+ "rules" : {}
38+ },
39+ "browserslist" : [
40+ " > 1%" ,
41+ " last 2 versions" ,
42+ " not dead"
43+ ]
44+ }
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="utf-8 " />
5+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge " />
6+ < meta name ="viewport " content ="width=device-width,initial-scale=1.0 " />
7+ < link rel ="icon " href ="<%= BASE_URL %>favicon.ico " />
8+ < title > < %= htmlWebpackPlugin.options.title %> </ title >
9+ < link
10+ rel ="stylesheet "
11+ href ="https://bootswatch.com/4/united/bootstrap.min.css "
12+ />
13+ </ head >
14+ < body >
15+ < noscript >
16+ < strong >
17+ We're sorry but < %= htmlWebpackPlugin.options.title %> doesn't work
18+ properly without JavaScript enabled. Please enable it to continue.
19+ </ strong >
20+ </ noscript >
21+ < div id ="app "> </ div >
22+ <!-- built files will be auto injected -->
23+ </ body >
24+ </ html >
Original file line number Diff line number Diff line change 1+ <template >
2+ <div class =" container" >
3+ <h1 class =" text-success text-center" >State Management with Vuex</h1 >
4+ <hr class =" my-2" />
5+ <app-result :counter =" counter" />
6+ <app-counter @updated =" counter+=$event" />
7+ <hr class =" my-3" />
8+ <app-fetch-todos-btn />
9+ <app-todos />
10+ </div >
11+ </template >
12+
13+ <script >
14+ import counter from " ./components/counter" ;
15+ import result from " ./components/result" ;
16+ import fetchTodosBtn from " ./components/FetchTodosBtn" ;
17+ import todos from " ./components/Todos" ;
18+ export default {
19+ name: " App" ,
20+ components: {
21+ appCounter: counter,
22+ appResult: result,
23+ appFetchTodosBtn: fetchTodosBtn,
24+ appTodos: todos,
25+ },
26+ data () {
27+ return {
28+ counter: 0 ,
29+ };
30+ },
31+ mounted () {
32+ console .log (this .$store .state );
33+ },
34+ };
35+ </script >
36+
37+ <style >
38+ button {
39+ box-shadow : none !important ;
40+ }
41+ ::-webkit-scrollbar {
42+ width : 0 ;
43+ }
44+ </style >
Original file line number Diff line number Diff line change 1+ <template >
2+ <div class =" container" >
3+ <button @click =" fetchTodos(start+=10)" class =" btn btn-sm btn-primary" >Fetch Todos</button >
4+ <button
5+ @click =" $store.commit('SET_TODO_TYPE', false)"
6+ class =" btn btn-sm btn-warning text-dark ml-2"
7+ >Show All Todos</button >
8+ <button
9+ @click =" $store.commit('SET_TODO_TYPE', true)"
10+ class =" btn btn-sm btn-success ml-2"
11+ >Show Only Completed Todos</button >
12+ <button class =" disabled btn btn-sm btn-info ml-2" >{{ todoType }}</button >
13+ </div >
14+ </template >
15+
16+ <script >
17+ import { mapActions , mapGetters } from " vuex" ;
18+ export default {
19+ name: " AppFetchTodosBtn" ,
20+ data () {
21+ return {
22+ start: - 10 ,
23+ };
24+ },
25+ computed: {
26+ ... mapGetters ([" todoType" ]),
27+ },
28+ methods: {
29+ ... mapActions ([" fetchTodos" ]),
30+ },
31+ };
32+ </script >
33+
34+ <style >
35+ .disabled {
36+ pointer-events : none !important ;
37+ }
38+ </style >
Original file line number Diff line number Diff line change 1+ <template >
2+ <div class =" container p-4" >
3+ <h5 class =" text-info" >
4+ Total Todos:
5+ <span class =" text-dark" >{{ $store.state.todos.length }}</span >
6+ </h5 >
7+ <h4 v-if =" $store.state.loading" class =" text-secondary text-center" >Loading ...</h4 >
8+ <ul v-else class =" list-group" >
9+ <div
10+ v-for =" (todo, i) in todos"
11+ :key =" todo.id"
12+ class =" list-group-item list-group-item-action flex-column align-items-start"
13+ >
14+ <div class =" d-flex w-100 justify-content-between" >
15+ <h5 class =" mb-1" >
16+ <span class =" text-danger" >{{ i + 1 }}</span >
17+ {{ todo.title }}
18+ </h5 >
19+ <small class =" text-success" >{{ !todo.completed ? '' : 'Completed'}}</small >
20+ </div >
21+ </div >
22+ </ul >
23+ </div >
24+ </template >
25+
26+ <script >
27+ export default {
28+ name: " Todos" ,
29+ computed: {
30+ todos () {
31+ if (this .$store .state .showCompleted ) {
32+ return this .$store .getters .completedTodos ;
33+ } else {
34+ return this .$store .state .todos ;
35+ }
36+ },
37+ },
38+ };
39+ </script >
40+
41+ <style scoped>
42+ .list-group-item {
43+ cursor : pointer ;
44+ }
45+ </style >
You can’t perform that action at this time.
0 commit comments