M
M
Mikhail Smirnov2020-11-26 12:35:00
Vue.js
Mikhail Smirnov, 2020-11-26 12:35:00

How to interact with external scripts in vuejs?

There is an online store

The task is to make a basket on vuejs, the
basket is always displayed on the page as a block

The product catalog is displayed in php, that is, just html

How to catch a click on the "Add to cart" button in the vue application? To update the list of goods in the basket

Now this is done on jquery , you press the
button, an ajax request goes to the server and then the list in the basket is updated

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Ineshin, 2020-11-26
@fortoster82

No one is stopping you from writing pure JS in Vue. For example, take the mounted callback and write your logic there.

mounted() {
  document.addEventListener('addToBasket', (e, data) => {
    // тут добавляете в свой стейт пришедшую дату и обновляете зависимые компоненты
  }
}

Let the "add to basket" button fire a custom event `addToBasket` ​​and pass the desired date there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question