R
R
Roman Rakzin2017-03-20 21:15:21
JavaScript
Roman Rakzin, 2017-03-20 21:15:21

How to compile text into a formula in vue.js?

We need to dynamically compile the vue.js formula based on data from the database.
For example, I get this value from the database {{1+MyParameter[1]}} .
Now the data is displayed "as is" (without recalculation). How can I compile the formula after getting it from the server?
Example
Vue.component('ColFormule', {
props: ['Column'],
template: '{{GetData}}',
computed: {
GetData:{
get: function () {
return this.Column;
}
}
},
} );
Column I stupidly write {{1+1}} , but as a result I get not a calculated value, but the same

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
wostex, 2017-03-20
@wostex

you can try https://github.com/handsontable/formula-parser
and return the calculation to the computed property

S
Stalker_RED, 2018-01-17
@Stalker_RED

p is paragraph. They cannot be nested.
Something like this: https://jsfiddle.net/t9kk78dv/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question