pvincent
4 years ago
5 changed files with 40 additions and 48 deletions
-
14.vscode/settings.json
-
2src/components/App.vue
-
46src/components/Basket.vue
-
24src/stores/global.ts
-
2tsconfig.json
@ -1,24 +1,24 @@ |
|||||
import { computed, reactive, readonly } from "vue" |
|
||||
|
import { computed, reactive, readonly } from 'vue' |
||||
|
|
||||
|
//CONSTANTS
|
||||
|
const TVA = 8.5 |
||||
|
|
||||
|
//STATE
|
||||
const state = reactive({ |
const state = reactive({ |
||||
count: 0, |
|
||||
|
count: 0 |
||||
}) |
}) |
||||
|
|
||||
const ttc = computed( |
|
||||
() => state.count * 1.085 |
|
||||
) |
|
||||
|
//COMPUTED
|
||||
|
const ttc = computed(() => (state.count * (100 + TVA)) / 100) |
||||
|
|
||||
|
//ARROW FUNCTION
|
||||
const inc = (amount: number): number => { |
const inc = (amount: number): number => { |
||||
return (state.count += amount) |
|
||||
|
return (state.count += amount) |
||||
} |
} |
||||
|
|
||||
|
//STANDARD FUNCTION
|
||||
function reset(): number { |
function reset(): number { |
||||
return state.count = 0 |
|
||||
|
return (state.count = 0) |
||||
} |
} |
||||
|
|
||||
export default { |
|
||||
state: readonly(state), |
|
||||
getters: { ttc }, |
|
||||
actions: { inc, reset } |
|
||||
} |
|
||||
|
export default { state: readonly(state), ttc, inc, reset } |
Write
Preview
Loading…
Cancel
Save
Reference in new issue