|
@ -3,30 +3,28 @@ |
|
|
<div> |
|
|
<div> |
|
|
<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="addProduct" |
|
|
> |
|
|
> |
|
|
order product n°{{ products }} |
|
|
|
|
|
|
|
|
order product n°{{ data.products }} |
|
|
</button> |
|
|
</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" |
|
|
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++" |
|
|
|
|
|
|
|
|
@click="data.price++" |
|
|
> |
|
|
> |
|
|
inc price {{ price }}€ |
|
|
|
|
|
|
|
|
inc price {{ data.price }}€ |
|
|
</button> |
|
|
</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" |
|
|
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" |
|
|
@click="decPrice" |
|
|
> |
|
|
> |
|
|
dec price {{ price }}€ |
|
|
|
|
|
|
|
|
dec price {{ data.price }}€ |
|
|
</button> |
|
|
</button> |
|
|
</div> |
|
|
</div> |
|
|
<p> |
|
|
|
|
|
TOTAL HT = {{ global.state.count }}€ <br /> |
|
|
|
|
|
TOTAL TTC = {{ global.getters.ttc.value }}€ |
|
|
|
|
|
</p> |
|
|
|
|
|
|
|
|
<p>TOTAL HT = {{ state.count }}€ <br /></p> |
|
|
|
|
|
<p>TOTAL HT = {{ ttc }}€ <br /></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="global.actions.reset()" |
|
|
|
|
|
|
|
|
@click="reset" |
|
|
> |
|
|
> |
|
|
RESET |
|
|
RESET |
|
|
</button> |
|
|
</button> |
|
@ -34,24 +32,28 @@ |
|
|
|
|
|
|
|
|
<script lang="ts"> |
|
|
<script lang="ts"> |
|
|
import global from '@/stores/global' |
|
|
import global from '@/stores/global' |
|
|
import { defineComponent, ref } from 'vue' |
|
|
|
|
|
|
|
|
import { defineComponent, reactive } from 'vue' |
|
|
|
|
|
|
|
|
export default defineComponent({ |
|
|
export default defineComponent({ |
|
|
props: { |
|
|
props: { |
|
|
msg: { type: String, required: true } |
|
|
msg: { type: String, required: true } |
|
|
}, |
|
|
}, |
|
|
setup() { |
|
|
setup() { |
|
|
const products = ref(1) |
|
|
|
|
|
const price = ref(5) |
|
|
|
|
|
return { products, price, global } |
|
|
|
|
|
}, |
|
|
|
|
|
methods: { |
|
|
|
|
|
inc1() { |
|
|
|
|
|
this.products++ |
|
|
|
|
|
global.actions.inc(this.price) |
|
|
|
|
|
}, |
|
|
|
|
|
decPrice() { |
|
|
|
|
|
if (this.price > 1) this.price-- |
|
|
|
|
|
|
|
|
const data = reactive({ |
|
|
|
|
|
products: 1, |
|
|
|
|
|
price: 10 |
|
|
|
|
|
}) |
|
|
|
|
|
const { state, ttc, inc, reset } = global |
|
|
|
|
|
|
|
|
|
|
|
function decPrice() { |
|
|
|
|
|
if (data.price > 1) data.price-- |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const addProduct = () => { |
|
|
|
|
|
data.products++ |
|
|
|
|
|
inc(data.price) |
|
|
} |
|
|
} |
|
|
|
|
|
return { data, state, ttc, reset, decPrice, addProduct } |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
</script> |
|
|
</script> |