E
E
Eugene2019-12-05 12:42:11
Vue.js
Eugene, 2019-12-05 12:42:11

How to dynamically change the value of an attribute?

I have an element that has its transform value changed.

<g id="wrapper-svg" transform="matrix(1, 0, 0, 1, 0, 0)"></g>

data stores the values ​​of matrix.
data() {
  return {
    matrix: {
        a: 1, 
        b: 0, 
        c: 0, 
        d: 1, 
        x: 0, 
        y: 0,
      }
  }
}

And when they change, I set the new values ​​using setAttribute
wrapper.setAttribute("transform", `matrix(${a}, ${b}, ${c}, ${d}, ${x}, ${y})`)

Is there a way to do this dynamically so that vue will listen for the values ​​and apply the changes?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2019-12-05
@you_are_enot

:transform="matrix"
Upd: hurried.
you can like this:

computed: {
  computedMatrix() => `matrix(${this.matrix.a}, ..., ..., ...)`
}

:transform="computedMatrix"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question