|
@ -1,18 +1,35 @@ |
|
|
<template> |
|
|
<template> |
|
|
<h1>{{ msg }}</h1> |
|
|
<h1>{{ msg }}</h1> |
|
|
|
|
|
<div> |
|
|
|
|
|
<button |
|
|
|
|
|
class="border border-purple-200 rounded-full font-semibold py-1 px-4 text-sm text-purple-600 hover:bg-purple-600 hover:border-transparent hover:text-white focus:outline-none focus:ring-2 focus:ring-purple-600 focus:ring-offset-2" |
|
|
|
|
|
@click="inc1" |
|
|
|
|
|
> |
|
|
|
|
|
order product n°{{ products }} |
|
|
|
|
|
</button> |
|
|
|
|
|
<button |
|
|
|
|
|
class="border border-purple-200 rounded-full font-semibold py-1 px-4 text-sm text-purple-600 hover:bg-purple-600 hover:border-transparent hover:text-white focus:outline-none focus:ring-2 focus:ring-purple-600 focus:ring-offset-2" |
|
|
|
|
|
@click="price++" |
|
|
|
|
|
> |
|
|
|
|
|
inc price {{ price }}€ |
|
|
|
|
|
</button> |
|
|
|
|
|
<button |
|
|
|
|
|
class="border border-purple-200 rounded-full font-semibold py-1 px-4 text-sm text-purple-600 hover:bg-purple-600 hover:border-transparent hover:text-white focus:outline-none focus:ring-2 focus:ring-purple-600 focus:ring-offset-2" |
|
|
|
|
|
@click="decPrice" |
|
|
|
|
|
> |
|
|
|
|
|
dec price {{ price }}€ |
|
|
|
|
|
</button> |
|
|
|
|
|
</div> |
|
|
|
|
|
<p> |
|
|
|
|
|
TOTAL HT = {{ global.state.count }}€ <br /> |
|
|
|
|
|
TOTAL TTC = {{ global.getters.ttc.value }}€ |
|
|
|
|
|
</p> |
|
|
<button |
|
|
<button |
|
|
class="border border-purple-200 rounded-full font-semibold py-1 px-4 text-sm text-purple-600 hover:bg-purple-600 hover:border-transparent hover:text-white focus:outline-none focus:ring-2 focus:ring-purple-600 focus:ring-offset-2" |
|
|
class="border border-purple-200 rounded-full font-semibold py-1 px-4 text-sm text-purple-600 hover:bg-purple-600 hover:border-transparent hover:text-white focus:outline-none focus:ring-2 focus:ring-purple-600 focus:ring-offset-2" |
|
|
@click="inc1" |
|
|
|
|
|
|
|
|
@click="global.actions.reset()" |
|
|
> |
|
|
> |
|
|
inc product {{ count1 }} |
|
|
|
|
|
|
|
|
RESET |
|
|
</button> |
|
|
</button> |
|
|
<button |
|
|
|
|
|
class="border border-purple-200 rounded-full font-semibold py-1 px-4 text-sm text-purple-600 hover:bg-purple-600 hover:border-transparent hover:text-white focus:outline-none focus:ring-2 focus:ring-purple-600 focus:ring-offset-2" |
|
|
|
|
|
@click="inc2" |
|
|
|
|
|
> |
|
|
|
|
|
inc {{ count2 }} |
|
|
|
|
|
</button> |
|
|
|
|
|
state = {{ state.count }} |
|
|
|
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script lang="ts"> |
|
|
<script lang="ts"> |
|
@ -23,19 +40,17 @@ export default defineComponent({ |
|
|
msg: { type: String, required: true } |
|
|
msg: { type: String, required: true } |
|
|
}, |
|
|
}, |
|
|
setup() { |
|
|
setup() { |
|
|
const count1 = ref(0) |
|
|
|
|
|
const count2 = ref(0) |
|
|
|
|
|
const { state } = global |
|
|
|
|
|
return { count1, count2, state } |
|
|
|
|
|
|
|
|
const products = ref(1) |
|
|
|
|
|
const price = ref(5) |
|
|
|
|
|
return { products, price, global } |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
inc1() { |
|
|
inc1() { |
|
|
console.warn(`inc1 ${this.count1}`) |
|
|
|
|
|
this.count1++ |
|
|
|
|
|
|
|
|
this.products++ |
|
|
|
|
|
global.actions.inc(this.price) |
|
|
}, |
|
|
}, |
|
|
inc2() { |
|
|
|
|
|
console.error(`inc2 ${this.count2}`) |
|
|
|
|
|
this.count2++ |
|
|
|
|
|
|
|
|
decPrice() { |
|
|
|
|
|
if (this.price > 1) this.price-- |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|