Dynamic Computed Property Vue

[Solved] Dynamic Computed Property Vue | Actionscript - Code Explorer | yomemimo.com
Question : dynamic computed property vue

Answered by : emmanuel-mahuni

computed: { element() { return this.getElements(...); },
},
watch: { element: { handler: function (newValue) { if (newValue.inputName) { this.addProp(['element', 'inputName'], () => { return 'someValue' }) } }, deep: true }
},
methods: { addProp (path, getter) { // Get property reference or undefined if not (yet) valid const propName = path.reduce((acc, prop) => acc ? acc[prop] : undefined, this) if (!propName) { return } const computedProp = { get() { return getter() } } this[propName] = computedProp },
}

Source : https://stackoverflow.com/questions/53332250/dynamic-computed-property-name | Last Update : Thu, 30 Sep 21

Answers related to dynamic computed property vue

Code Explorer Popular Question For Actionscript